The `CUDA_PROPAGATE_HOST_FLAGS` and `CUDA_SEPARABLE_COMPILATION` are global variables ( use `set` ) not a target properties. You can find more documentation on the legacy cuda support variable in the find cuda module ( https://cmake.org/cmake/help/latest/module/FindCUDA.html ).
On Mon, Jul 9, 2018 at 9:52 AM Quang Ha <quang.t.ha...@gmail.com> wrote: > Hi all, > > The situation I am currently in is as followed. This is the directory for > my project: > > project > |----------CMakeLists.txt > |----------app > | |--------CMakeLists.txt > | |--------test_cuda > | |--------CMakeLists.txt > | |--------test_cuda.cu > |----------src > |----------test > |----------doc > > Inside project/app/CMakeLists.txt, it looks like this: > ## > add_subdirectory(test_cuda) > ## > and then inside project/app/test_cuda/CMakeLists.txt, it is: > ## > find_package(CUDA REQUIRED) > > if (CUDA_FOUND) > # CUDA falgs > include_directories(${CUDA_INCLUDE_DIRS}) > set(ALL_CUDA_LIBS ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} > ${CUDA_cublas_LIBRARY}) > set(LIBS ${LIBS} ${ALL_CUDA_LIBS}) > set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--maxrregcount 32) > # set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode > arch=compute_70,code=sm_70) > > # Link to executable > cuda_add_executable(test_cuda test_cuda.cu) > # set_target_properties(test_cuda PROPERTIES COMPILE_FLAGS > "-DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA") > set_target_properties(test_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION > ON) > set_target_properties(test_cuda PROPERTIES CUDA_PROPAGATE_HOST_FLAGS > OFF) > target_link_libraries(test_cuda ${LIBS} ${EXTRA_LIBS}) > endif() > ## > > There is nothing special inside test_cuda.cu - since I just want to test > cmake integration: > ## > #include <stdio.h> > #include <fstream> > > __global__ > void kernel (void){ > } > > int main(void ) { > kernel<<<1,1>>>(); > return 0; > } > ## > > I got an error when running cmake with this: > > ### > [ 75%] Building NVCC (Device) object > app/test_cuda/CMakeFiles/test_cuda.dir/test_cuda_generated_test_cuda.cu.o > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(200): > error: statement may not appear in a constexpr function > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(202): > error: a constexpr function must contain exactly one return statement > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(224): > error: statement may not appear in a constexpr function > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(226): > error: a constexpr function must contain exactly one return statement > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(246): > error: statement may not appear in a constexpr function > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(248): > error: a constexpr function must contain exactly one return statement > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(268): > error: statement may not appear in a constexpr function > > /projects/opt/centos7/gcc/6.4.0/include/c++/6.4.0/bits/stl_algobase.h(270): > error: a constexpr function must contain exactly one return statement > > 8 errors detected in the compilation of > "/tmp/tmpxft_00003241_00000000-4_test_cuda.cpp4.ii". > CMake Error at test_cuda_generated_test_cuda.cu.o.Release.cmake:279 > (message): > Error generating file > > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > ### > > Checking with make VERBOSE=1: > > ## > [ 75%] Building NVCC (Device) object > app/test_cuda/CMakeFiles/test_cuda.dir/test_cuda_generated_test_cuda.cu.o > cd > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir && > /projects/opt/centos7/cmake/3.11.1/bin/cmake -E make_directory > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//. > cd > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir && > /projects/opt/centos7/cmake/3.11.1/bin/cmake -D verbose:BOOL=1 -D > build_configuration:STRING=Release -D > generated_file:STRING=/home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > -D > generated_cubin_file:STRING=/home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o.cubin.txt > -P > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.Release.cmake > -- Removing > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > /projects/opt/centos7/cmake/3.11.1/bin/cmake -E remove > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > -- Generating dependency file: > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.NVCC-depend > /projects/opt/centos7/cuda/9.1/bin/nvcc -M -D__CUDACC__ > /home/qth20/develop/project/app/test_cuda/test_cuda.cu -o > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.NVCC-depend > -ccbin /projects/opt/centos7/gcc/6.4.0/bin/gcc -m64 -DTHRUST > -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP > -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA > "-DCUDA_CALLABLE=\"__host__ __device__\"" -Xcompiler > ,\"-std=c++14\",\"-O3\",\"-DNDEBUG\" --std=c++11 --expt-relaxed-constexpr > -Xcompiler -fPIC --maxrregcount 32 -DNVCC > -I/projects/opt/centos7/cuda/9.1/include -I/home/qth20/develop/project > -I/home/qth20/develop/project/build > -I/home/qth20/develop/project/cinch/logging > -I/projects/opt/centos7/openmpi/3.1.0-gcc_8.1.0/include /UnitTest++ > -- Generating temporary cmake readable file: > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > /projects/opt/centos7/cmake/3.11.1/bin/cmake -D > input_file:FILEPATH=/home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.NVCC-depend > -D > output_file:FILEPATH=/home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > -D verbose=1 -P > /projects/opt/centos7/cmake/3.11.1/share/cmake-3.11/Modules/FindCUDA/make2cmake.cmake > -- Copy if different > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > to > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend > /projects/opt/centos7/cmake/3.11.1/bin/cmake -E copy_if_different > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend > -- Removing > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > and > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.NVCC-depend > /projects/opt/centos7/cmake/3.11.1/bin/cmake -E remove > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.depend.tmp > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//test_cuda_generated_test_cuda.cu.o.NVCC-depend > -- Generating > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > /projects/opt/centos7/cuda/9.1/bin/nvcc > /home/qth20/develop/project/app/test_cuda/test_cuda.cu -c -o > /home/qth20/develop/project/build/app/test_cuda/CMakeFiles/test_cuda.dir//./test_cuda_generated_test_cuda.cu.o > -ccbin /projects/opt/centos7/gcc/6.4.0/bin/gcc -m64 -DTHRUST > -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP > -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA > "-DCUDA_CALLABLE=\"__host__ __device__\"" -Xcompiler > ,\"-std=c++14\",\"-O3\",\"-DNDEBUG\" --std=c++11 --expt-relaxed-constexpr > -Xcompiler -fPIC --maxrregcount 32 -DNVCC > -I/projects/opt/centos7/cuda/9.1/include -I/home/qth20/develop/project > -I/home/qth20/develop/project/build > -I/home/qth20/develop/project/cinch/logging > -I/projects/opt/centos7/openmpi/3.1.0-gcc_8.1.0/include /UnitTest++ > [Error] > ## > > It looks like all the flags used in gcc is passed directly into nvcc. Is > there a way to turn this off? > > Thanks, > Quang > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > https://cmake.org/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake