View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015239CMakeCMakepublic2014-11-11 06:532015-04-06 09:07
ReporterDavidSto 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake 2.8.12 
Target VersionFixed in Version 
Summary0015239: Escape %3B in preprocessor definitions
DescriptionBug fix:
http://www.cmake.org/pipermail/cmake-commits/2013-April/014836.html [^]
(Escape ; as %3B in preprocessor definitions - replace ; with %3B)
breaks the preprocessor definitions in Visual Studio 2012 (VS11)

It generates one line instead line breaks.
For example: "NDEBUG%3BwxDEBUG_LEVEL=0%3BFULLVERSION" instead of
NDEBUG
wxDEBUG_LEVEL=0
FULLVERSION
(with line breaks)
Steps To Reproduceset(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} "wxDEBUG_LEVEL=0;FULLVERSION")
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} "wxDEBUG_LEVEL=0;FULLVERSION")
TagsNo tags attached.
Attached Files

 Relationships
related to 0014073closedBrad King VS2010 / VS2012 - Improper escape of semicolon in compile definition 

  Notes
(0037171)
Brad King (manager)
2014-11-11 08:36

Add the definition using add_definitions or by setting a COMPILE_DEFINITIONS property. CMake knows how to escape those.

The *_FLAGS_* variable values go through without interpretation by CMake, and then the VS IDE project file format divides flags on ;.
(0037172)
DavidSto (reporter)
2014-11-11 08:58

But this was not usable with custom CMAKE_CONFIGURATION_TYPES with the same or different preprocessor flags.
add_definitions are for all targets and all configuration types.
COMPILE_DEFINITIONS are for one target.
cmake 2.8.11 is the latest version it works.

For example:
        set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Release_Full" CACHE STRING "limited configs" FORCE)
#release has the flag debug level = 0 for all targets
        set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} "wxDEBUG_LEVEL=0")
        set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} "wxDEBUG_LEVEL=0")
#release full -> grab release c and cxx flags and add some custom flags
        set(CMAKE_CXX_FLAGS_RELEASE_FULL ${CMAKE_CXX_FLAGS_RELEASE} "FULLVERSION;wxDEBUG_LEVEL=0")
        set(CMAKE_C_FLAGS_RELEASE_FULL ${CMAKE_C_FLAGS_RELEASE} "FULLVERSION;wxDEBUG_LEVEL=0")
(0037173)
Brad King (manager)
2014-11-11 09:04
edited on: 2014-11-11 09:08

The COMPILE_DEFINITIONS property is available at directory scope too. That's where add_definitions puts things. We've had COMPILE_DEFINITIONS_<CONFIG> properties for a long time to get per-config defintions. Since 2.8.10 the preferred way is to use generator expressions:

set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release_Full>:FULLVERSION>)

(0037174)
Brad King (manager)
2014-11-11 09:07

Re 0015239:0037171: Oops, I read the description backwards. CMake 2.8.12 is correctly escaping the ; in the flags as %3B. The *_FLAGS_* variables are considered to be command-line fragments and therefore space-separated. If you really don't want to use COMPILE_DEFINITIONS then add "-DFULLVERSION -DwxDEBUG_LEVEL=0" to the flags values.
(0037175)
DavidSto (reporter)
2014-11-11 09:28

No problem.
Checked something:
I added "-DFULLVERSION -DwxDEBUG_LEVEL=0" to the compile variables.
Result:
set(CMAKE_CXX_FLAGS_RELEASE_FULL ${CMAKE_CXX_FLAGS_RELEASE} "-DFULLVERSION -DwxDEBUG_LEVEL=0")
set(CMAKE_C_FLAGS_RELEASE_FULL ${CMAKE_C_FLAGS_RELEASE} "-DFULLVERSION -DwxDEBUG_LEVEL=0")

cmake version 2.8.11.2 (not 2.8.12) generates -DwxDEBUG_LEVEL=0 -DFULLVERSION with an break (right)
cmake version 2.8.12.2 and higher -> after your patch generates: %3B-DwxDEBUG_LEVEL=0%3B-DFULLVERSION
it's not working with an space. And -D is for *nix flags.
(0037176)
Brad King (manager)
2014-11-11 09:29

set(CMAKE_CXX_FLAGS_RELEASE_FULL "${CMAKE_CXX_FLAGS_RELEASE} -DFULLVERSION -DwxDEBUG_LEVEL=0")
set(CMAKE_C_FLAGS_RELEASE_FULL "${CMAKE_C_FLAGS_RELEASE} -DFULLVERSION -DwxDEBUG_LEVEL=0")
(0037177)
Brad King (manager)
2014-11-11 09:32

The *_FLAGS_* variables have always been treated as a single string to put on the command line. The fact that ; worked before in the VS IDE generator before the fix in 2.8.12 was an accident, and it was actually the IDE that separated on ;. The fix made it possible to pass ; in definition values.
(0037179)
DavidSto (reporter)
2014-11-11 10:30

set(CMAKE_CXX_FLAGS_RELEASE_FULL "${CMAKE_CXX_FLAGS_RELEASE} -DFULLVERSION -DwxDEBUG_LEVEL=0")
set(CMAKE_C_FLAGS_RELEASE_FULL "${CMAKE_C_FLAGS_RELEASE} -DFULLVERSION -DwxDEBUG_LEVEL=0")

works. :) so we can close the ticket.
(0038441)
Robert Maynard (manager)
2015-04-06 09:07

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-11-11 06:53 DavidSto New Issue
2014-11-11 08:33 Brad King Relationship added related to 0014073
2014-11-11 08:36 Brad King Note Added: 0037171
2014-11-11 08:58 DavidSto Note Added: 0037172
2014-11-11 09:04 Brad King Note Added: 0037173
2014-11-11 09:07 Brad King Note Added: 0037174
2014-11-11 09:08 Brad King Note Edited: 0037173
2014-11-11 09:28 DavidSto Note Added: 0037175
2014-11-11 09:29 Brad King Note Added: 0037176
2014-11-11 09:32 Brad King Note Added: 0037177
2014-11-11 10:30 DavidSto Note Added: 0037179
2014-11-11 10:34 Brad King Status new => resolved
2014-11-11 10:34 Brad King Resolution open => no change required
2015-04-06 09:07 Robert Maynard Note Added: 0038441
2015-04-06 09:07 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team