Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22148

CMake passes all gcc flags to nvcc as well

$
0
0

My project uses cuda kernel for a small module and needs nvcc for compiling. During compilation, cmake pass the same linker and compiler flags intended for gcc to nvcc as well. In my particular case, I get the following error.

nvcc fatal   : Unknown option 'Wl,--no-as-needed'

Following the accepted answer in this thread, I managed to remove the compiler flags for the target that needs nvcc as follows.

get_target_property(_target_cxx_flags target_that_needs_nvcc COMPILE_OPTIONS)
list(REMOVE_ITEM _target_cxx_flags "-fcolor-diagnostics")

Using this, I avoided the errors due to wrong compiler flags like this:

nvcc fatal   : Unknown option 'fdiagnostics-color'

But I cannot use the same procedure to remove linker flags because get_target_property fetches only compiler flags and not linker flags.

I am looking for a solution to disable the linker flags for just one target compilation.

The cmake minimum version expected is VERSION 3.0


Viewing all articles
Browse latest Browse all 22148

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>