La bla bla
La bla bla

Reputation: 8708

CMake passes C++ arguments to nvcc

I'm working on a project that mixes C++ and CUDA. In addition it links 3rd party libraries, specifically we suspect this problem comes from aws-sdk-c++.

The problem is that when we link against our libraries that uses AWS, a -pthread flag is added to the compile options of our target. Our target project has both .cpp & .cu files so when nvcc compiles and the flags are propagated from the host to the device compilation, we get

nvcc fatal : Unknown option 'pthread'

Looking around this problem happens quite a lot, the problem is that it's solution is often either using an older CMake which uses CUDA_ADD_LIBRARY in which the problem doesn't happen and one can set the CUDA_PROPAGATE_HOST_FLAGS=OFF to fix this, or it's a matter of specifying the offending pthread flag in a generator expressions such as

add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${my_cxx_flags}>")
add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:${my_cuda_flags}>")

(taken from this answer) Which is not an option for us since we don't include the pthread flag ourselved but thru a 3rd party that we link against.

So I'm guessing my question is, is there a way in modern CMake to prevent the propagation of the host flags to nvcc, or maybe removing specific flags from nvcc, since we know what causes our problems.

Or any other solution to allow us to compile CUDA files using nvcc in a library this links against pthread

Upvotes: 4

Views: 826

Answers (1)

La bla bla
La bla bla

Reputation: 8708

Looks like there was a bug in CMake mixed with CUDA 10.0. Upgrading to CMake 3.17.3 as suggested here didn't solve it until I upgraded to CUDA 10.2, in that case CMake 3.17.3 worked

Upvotes: 4

Related Questions