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