Turning on linker flags with CMake

后端 未结 5 1256
萌比男神i
萌比男神i 2020-12-30 00:37

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)

5条回答
  •  无人及你
    2020-12-30 01:22

    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).

提交回复
热议问题