When generating VS2010 targets with CMake, I would like the /LTCG flag turned on (only for release + releasewithdebinfo if possible, but its okay if its on for debug builds). How do I modify the linker flags? add_definitions()
doesn't work because that only modifies compiler flags. And yes, I have wrapped it in if(MSVC).
How do I modify the linker flags?
Right-click the target in the Xcode Groups and Files list and select Get Info from the contextual menu. In the Build tab, type linker into the search field and then locate the Other Linker Flags item. Double-click the Other Linker Flags item and add -lgmp .
Open your project and then go Project > Build Options > Compiler Flags . You can tick boxes in the "Compiler Flags" tab, and you can write other options in the "Other Options" tab. Do one or the other, e.g. don't tick the "-std=c++98" box and also put "-std=c++11" in the Other Options.
This is a CMake Environment Variable. Its initial value is taken from the calling process environment. Default compilation flags to be used when compiling C files.
You can modify the linker flags in MSC using #pragma comment(linker, ...)
However, if you'd like to do it in the build process with cmake, here are the names you need to know:
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
(Thanks to Cmake.org).
and STATIC_LIBRARY_FLAGS http://www.cmake.org/cmake/help/v2.8.8/cmake.html#prop_tgt:STATIC_LIBRARY_FLAGS
for static libraries
For adding linker flags - the following 4 CMake variables:
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
CMAKE_STATIC_LINKER_FLAGS
can be easily manipulated for different configs (debug, release...) with the ucm_add_linker_flags macro of ucm
linker flags can also be managed on a per-target basis - by using target_link_libraries and passing flags with a -
in front of them (but not with a -l
- that would be treated as a link library and not a link flag).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With