I have to a build cuda library with meson and the flags I need to provide are:
NVCCFLAGS = -ccbin g++ --threads 0 -std=c++17 -c -arch=sm_86 -gencode arch=compute_61,code=sm_61 -m64
the meson.build is
# Builds lib-gpu as a dependency called "lib_gpu_dep".
add_languages('cuda')
subdir('src')
project_source_files = [
source_files_src,
]
build_args_common = [
'-ccbin',
'g++',
'-c',
'-arch=sm_86',
'-gencode arch=compute_61,code=sm_61',
'-m64',
]
if (get_option('unit_test'))
build_args = [build_args_common,
'-g',
'-G',
'-DDEBUG=1'
]
else
build_args = [
build_args_common,
'-src-in-ptx',
' -keep',
# '--keep-dir=build/$(BUILD_TYPE)',
' --use_fast_math',
' -lineinfo'
]
endif
cuda_src_dir = '/usr/local/cuda'
inc_dir_cuda = include_directories(cuda_src_dir + '/include')
lib_gpu_incdir = include_directories('inc', is_system : true)
lib_gpu_name = 'lib_gpu'
lib_gpu = static_library(
lib_gpu_name,
project_source_files,
cuda_args : build_args,
gnu_symbol_visibility : 'default',
include_directories : [lib_gpu_incdir, inc_dir_cuda])
lib_gpu_dep = declare_dependency(
include_directories : lib_gpu_incdir,
link_with : lib_gpu
)
in the generated ninja file I have
ARGS = -Ilib-gpu/liblib_gpu.a.p -Xcompiler=-Wall,-Winvalid-pch,-Wnon-virtual-dtor,-Wextra,-Wpedantic -Xcompiler=-fPIC -I/usr/local/cuda/include -I/usr/local/cuda/include -isystem=../lib-gpu/inc -ccbin g++ -c -arch=sm_86 '-gencode$ arch=compute_61,code=sm_61' -m64 -Wno-pedantic -g -G -DDEBUG=1 -I../lib-gpu -Ilib-gpu -Ilib-gpu/liblib_gpu.a.p
but the flags '-gencode$ arch=compute_61,code=sm_61'
is not correct
and in order to compile I need to modify it with a script to
-gencode arch=compute_61,code=sm_61
is there a way to solve this problem? the version used is
meson --version
0.59.1
instead to use
'-gencode arch=compute_61,code=sm_61',
is it possible to write
'-gencode=arch=compute_61,code=sm_61',
in this case the flag generated by meson is correct.