[CMake] Default compiler and linker flags with VS2010
Michael Stürmer
m.stuermer at pmdtec.com
Mon Jan 16 05:02:00 EST 2012
Hi there,
I want to automate a build of my software package. For that I use the "NMake Makefiles" generator and Visual Studio 2010. Even though I set all the necessary linker the way that my visual studio solution does not generate any error, I get warnings when I compile the NMake-way:
LINK: warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
Now that is a very clear statement. INCREMENTAL is switched on and should be off. But in my CMAke scripts I set it to off:
SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG /INCREMENTAL:NO /DYNAMICBASE:NO /MACHINE:X86" )
Now when I serach for the corresponding makefile I find the following:
... /STACK:10000000 /machine:X86 /LTCG /INCREMENTAL:NO /DYNAMICBASE:NO /MACHINE:X86 /debug /INCREMENTAL ...
I also found the following part in the Windows-cl.cmake within the Modules/Platform-folder in the CMake installation directory:
IF (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
ELSE (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}")
ENDIF (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
# for release and minsize release default to no incremental linking
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT "/INCREMENTAL:NO")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:NO")
Why or how does CMake add the /INCREMENTAL-thing again if I switched it off before? How can I change the default behavior in a way that I get rid of the warnings? What is the exact order and how are the different variables like CMAKE_SHARED_LINKER_FLAGS_INIT CMAKE_SHARED_LINKER_FLAGS etc. combined? This really frustrates me at the moment.
Any help appreciated, ...
More information about the CMake
mailing list