Issues passing arguments to nvcc using enable_language(CUDA)
When compiling a module that uses AWS (not related to AWS, this is just what triggered it for me) I started getting compilation erros nvcc fatal : Unknown option 'pthread'
After digging and finding where this pthread
flag came from I filed a bug report on the (AWS c++ sdk)
Later I found that it seems to be caused by using the new enable_language(CUDA)
. Changing to find_package(CUDA)
solved the issue
Minimal sample code:
CMakeLists.txt
----------------
cmake_minimum_required (VERSION 3.12)
enable_language(CUDA) # Changing this to find_package(CUDA) solves the problem
find_package(AWSSDK REQUIRED COMPONENTS s3)
add_executable(exec main.cpp cuda.cu)
target_link_libraries(exec
${AWSSDK_LINK_LIBRARIES})
main.cpp
-----------
#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
cuda.cu
is empty
Output:
Scanning dependencies of target exec
[ 25%] Building CXX object CMakeFiles/exec.dir/main.cpp.o
[ 50%] Building CUDA object CMakeFiles/exec.dir/cuda.cu.o
nvcc fatal : Unknown option 'pthread'
CMakeFiles/exec.dir/build.make:75: recipe for target 'CMakeFiles/exec.dir/cuda.cu.o' failed
make[3]: *** [CMakeFiles/exec.dir/cuda.cu.o] Error 1
My system is Ubuntu 16.04
CUDA version 10.0.130
CMake 3.14