The first two had no effect. It did not set any flag. The last seemed to work, but I want a way to change flags inside the CMake file, not in the command line.
So how do I set flags inside the CMakeLists.txt file?
I have read the explanation in that you linked, but I don’t understand the difference between the two ( why the former doesn’t work where as the latter does )
CMake went through a significant change in how it dealt with CUDA in the 3.8 - 3.12 timeframe.
You can read about it on the CMake github site:
The set(CUDA_NVCC_FLAGS… syntax was part of the old (deprecated) methodology. The target_compile_options(… syntax is part of the new methodology (so called “first class language support”).
Your first approach will tell the “whole world” (all the targets) what CUDA flags to use (this is the old way of using CMake).
The second approach sets the flags for “target” only, and by setting it to private the flags will not be inherited by anyone linking with “target”.
The idea is that all your different targets are objects that have properties that can be set/get. They can also inform other targets what is required to link with your target. It’s important to learn the difference between private/public.
This is a very powerful modular approach, that really lets you build large software projects IMO.
but it always fails to link the nvsheme library, and it returns me errors like undefined reference to nvsheme_
Could you please help me with this problem?
The CMake target_link_libraries command automatically adds the -llibrary-name option to the command line. You don’t need to add it again using target_compile_options. As for the undefined reference, is “nvsheme_” spelled correctly?