How to enable /INCREMENTAL:YES for release builds with cmake on Windows

不羁岁月 提交于 2020-01-25 02:07:13

问题


I need to use the linker flag /INCREMENTAL:YES when building some libraries with Visual Studio, but cmake seems to insist on using /INCREMENTAL:NO with release builds, and I can't figure out how to fix it. Some of the stuff that I've tried is

set(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:YES")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:YES")
set(CMAKE_EXE_LINKER_FLAGS_INIT "/INCREMENTAL:YES")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:YES")
set(CMAKE_CXX_FLAGS_RELEASE "/INCREMENTAL:YES ${CMAKE_CXX_FLAGS_RELEASE}")

Nothing fixes the problem. As far as I can tell, cmake is just plain hardwired to think that a release build must use /INCREMENTAL:NO. Does anyone know how to fix that and make it use /INCREMENTAL:YES?


回答1:


I've check CMakeCache.txt file and found more flags:

CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE

But I can't verify my assumption, seems like simply updating CMAKE_EXE_LINKER_FLAGS_RELEASE works fine for me (MSVC 2012, CMake 2.8.10), /INCREMENTAL:NO changed to /INCREMENTAL.



来源:https://stackoverflow.com/questions/18501121/how-to-enable-incrementalyes-for-release-builds-with-cmake-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!