I am trying to compile my project with cmake, but it's difficult. My project compile with one simple make, but not with cmake. The error is during the link. CMake prefers launch g++ ... -o ... instead of nvcc ... -o ...
If I force nvcc, the error is -rdynamic is unknown.
So, it's my cmake file
cmake_minimum_required(VERSION 2.8)
project(LightRays)
find_package(CUDA QUIET REQUIRED)
list(APPEND CUDA_NVCC_FLAGS "-std=c++11;-rdc=true")
file(GLOB_RECURSE
source_file
src/*
include/*)
CUDA_ADD_EXECUTABLE(LightRays ${source_file})
target_link_libraries(LightRays -lSDL -L/opt/cuda/lib64 -lcuda -lcudart)
add_definitions(-std=c++11)
target_link_libraries(LightRays -lSDL -L/opt/cuda/lib64 -lcuda -lcudart)
add_definitions(-std=c++11)
and here errors :
/tmp/tmpxft_00006509_00000000-4_global.cudafe1.stub.c:8: référence indéfinie vers « __cudaRegisterLinkedBinary_41_tmpxft_00006509_00000000_7_global_cpp1_ii_0ad406bb »
CMakeFiles/LightRays.dir/src/tools/LightRays_generated_tools.cu.o: dans la fonction « __sti____cudaRegisterAll_40_tmpxft_00006518_00000000_7_tools_cpp1_ii_278b9139() »:
....
EDIT : After answer, I changed my CMakeLists.txt by this one :
cmake_minimum_required(VERSION 3.0)
project(LightRays)
find_package(CUDA REQUIRED)
list(APPEND CUDA_NVCC_FLAGS "-std=c++11 -rdc=true")
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
add_definitions(-std=c++11)
set(CUDA_SEPARABLE_COMPILATION ON)
file(GLOB_RECURSE
source_file
src/*
include/*)
cuda_add_executable(LightRays ${source_file})
target_link_libraries(LightRays -lSDL)
And now, I have these errors :
CMake Error at /usr/share/cmake-3.2/Modules/FindCUDA.cmake:1455 (_cuda_get_important_host_flags):
_cuda_get_important_host_flags Function invoked with incorrect arguments
for function named: _cuda_get_important_host_flags
Call Stack (most recent call first):
/usr/share/cmake-3.2/Modules/FindCUDA.cmake:1570 (CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS)
CMakeLists.txt:17 (cuda_add_executable)
-- Configuring incomplete, errors occurred!
See also "/home/qnope/Programmation/cuda/LightRay/build/CMakeFiles/CMakeOutput.log".