[CMake] Problem when linking a library on a target with CUDA sources
victornement at free.fr
victornement at free.fr
Thu Jan 3 13:31:32 EST 2019
Hello,
I have a project with a few dependencies (Qt, opencv, aravis, etc) and I would like to add some sources in CUDA.
Here is a minimal example:
cmake_minimum_required(VERSION 3.0)
project(myproject CXX CUDA)
find_package(Qt5 REQUIRED COMPONENTS Core)
add_executable(mytarget main.cpp gpu.cu)
target_link_libraries(mytarget PUBLIC Qt5::Core)
The previous example gives the following output
[ 25%] Building CUDA object CMakeFiles/mytarget.dir/gpu.cu.o
nvcc fatal : Unknown option 'fPIC'
make[2]: *** [CMakeFiles/mytarget.dir/build.make:76: CMakeFiles/mytarget.dir/gpu.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/mytarget.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I would get the same problem if I replace target_link_libraries with
set_target_properties(mytarget PROPERTIES COMPILE_OPTIONS -pthread)
Does anyone know why I get this error? Am I doing it rightly? Is it a bug?
Sincerely,
Victor ML
More information about the CMake
mailing list