问题描述
当使用CMake生成VS2010目标时,我希望打开/ LTCG标志(只有在可能的情况下为release + releasewithdebinfo,但是如果它在调试时生效,它就OK了)。如何修改链接器标志? add_definitions()
不工作,因为只修改编译器标志。是的,我已经把它包装在if(MSVC)。
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).
如何修改链接器标志?
推荐答案
您可以使用#pragma comment(linker,...)修改MSC中的链接器标记
You can modify the linker flags in MSC using #pragma comment(linker, ...)
d喜欢在cmake的构建过程中这样做,下面是您需要知道的名称:
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
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
(感谢)。
这篇关于使用CMake打开链接器标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!