View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007476CMakeCMakepublic2008-08-09 22:152008-08-10 11:03
Reporterc0uch 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0007476: CMAKE_EXE_LINKER_FLAGS can produce bad solution configuration for VS2005 and 2008
DescriptionAdding the following to a basic cmake project (cmakelist.txts attached) results in the following issues:

SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " /NODEFAULTLIB:MSVCRT ")

1. If the value added (in this case " NODEFAULTLIB:MSVCRT ") does not have a blank space between the opening " and the text the linker additional commandline options entry is messed up:
 /STACK:10000000 /machine:I386";" /debug
(a mysterious ";")

2. If 2 modifications are made:
  SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " /NODEFAULTLIB:MSVCRT ")
  SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " /INCREMENTAL:NO ")
The second one appears to be ignored completely in the resulting sln file.

3. If you print out the value of CMAKE_EXE_LINKER_FLAGS they appear to be correct:
message("CMAKE_EXE_LINKER_FLAGS: " ${CMAKE_EXE_LINKER_FLAGS})
Produces:
CMAKE_EXE_LINKER_FLAGS: /MANIFEST /STACK:10000000 /machine:I386 /NODEFAULTLIB:MSVCRT /INCREMENTAL:NO
However, if you print it out again, in a separate cmakelists.txt file, the .sln is further modified (another ";" appears somewhere which I haven't yet been able to locate, but which causes linking to fail completely)
TagsNo tags attached.
Attached Fileszip file icon example_linker_options_fail.zip [^] (1,813 bytes) 2008-08-09 22:15

 Relationships

  Notes
(0012977)
c0uch (reporter)
2008-08-09 22:24

Looks like this may have just been a case of naivety on my part.

If I use
SET_TARGET_PROPERTIES(idkfa PROPERTIES LINK_FLAGS " /NODEFAULTLIB:MSVCRT /INCREMENTAL:NO")
instead then everything seems to work fine.

The method I was using (and what this ticket was about) is mentioned a few times in google searches for cmake link flags, so maybe there should be some note somewhere if one way is better than the other (in the reference documentation?)
(0012978)
Bill Hoffman (manager)
2008-08-10 11:03

Please see these:

http://www.cmake.org/HTML/syntax.html [^]
http://www.cmake.org/Wiki/CMake/Language_Syntax [^]

You want this:

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT ")

The ; is the list separator for cmake, so set(a b c) would be a;b;c. If you put the whole expression in "" then it will work fine.

 Issue History
Date Modified Username Field Change
2008-08-09 22:15 c0uch New Issue
2008-08-09 22:15 c0uch File Added: example_linker_options_fail.zip
2008-08-09 22:24 c0uch Note Added: 0012977
2008-08-10 11:03 Bill Hoffman Note Added: 0012978
2008-08-10 11:03 Bill Hoffman Status new => closed
2008-08-10 11:03 Bill Hoffman Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team