View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012327CMakeCMakepublic2011-07-10 22:302016-06-10 14:31
ReporterRyan H. Kawicki 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformMicrosoft WindowsOSWindows 7OS VersionSP1 64-bit
Product VersionCMake 2.8.5 
Target VersionFixed in Version 
Summary0012327: Appending Multiple COMPILE_FLAGS Produces Unexpected Results
DescriptionWhen appending multiple compile flags to to a specific target, the final generated project file does not produce the correct information.

For Example:
###############################################
MACRO (ADD_COMPILER_FLAGS TargetProject Flags)
  SET_PROPERTY(TARGET ${TargetProject}
               APPEND PROPERTY
               COMPILE_FLAGS ${Flags})
ENDMACRO (ADD_COMPILER_FLAGS)

SET (SRC_FILES
Main.cpp
StdAfx.cpp
StdAfx.h)

ADD_EXECUTABLE(CMakeBugPrj WIN32 ${SRC_FILES})

ADD_COMPILER_FLAGS(CMakeBugPrj /wd4244)
ADD_COMPILER_FLAGS(CMakeBugPrj /wd4311)
ADD_COMPILER_FLAGS(CMakeBugPrj /wd4312)
###############################################

One would expect that the command line being passed to cl.exe would get /wd"4244" /wd"4311" /wd"4312", but instead it is getting /wd"4244" /wd"/wd4311" /wd"/wd4312".

To get around this issue, I was previously quoting the macro ${Flags} as " ${Flags}", but I came upon another issue that is now somewhat blocking me. I have another macro that also appends to the compiler flags list, but this time a semicolon is getting appended to the flag. This is causing the compiler to barf.
Steps To ReproduceSample code provided.
Additional InformationI've tracked the issue down to two locations:

cmProperty::Append - this function will append a semicolon if there is more than one option present.

cmSystemTools::ParseWindowsCommandLine - this function will jam all the arguments into one argument.

For example:
Project compile flags are set to "/Yu"StdAfx.h" /Yc"StdAfx.pch";/wd4244;/wd4311;/wd4312"

The project level compiler flags are separating the individual flags with a semicolon. When the generator begins generating the final output, it will take the project level compile flags and try to split out the arguments based on parsing the windows command line. According the the link, this is space separated, which means that the example above is actually two command line arguments.

I guess my recommendation, if I have one, is to determine a better solution for appending multiple compile flags. I would suggest a set of strings.
TagsNo tags attached.
Attached Fileszip file icon CMakeBug.zip [^] (1,266 bytes) 2011-07-10 22:30

 Relationships
related to 0012342closedAlex Neundorf Using set_property(...APPEND) for COMPILE_FLAGS result in semicolons in the build command line 

  Notes
(0030278)
David Cole (manager)
2012-08-11 11:38

Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041860)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2011-07-10 22:30 Ryan H. Kawicki New Issue
2011-07-10 22:30 Ryan H. Kawicki File Added: CMakeBug.zip
2011-07-15 15:01 Alex Neundorf Relationship added related to 0012342
2012-08-11 11:38 David Cole Status new => backlog
2012-08-11 11:38 David Cole Note Added: 0030278
2016-06-10 14:28 Kitware Robot Note Added: 0041860
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team