Notes |
|
(0037171)
|
Brad King
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
2015-04-06 09:07
|
|
Closing resolved issues that have not been updated in more than 4 months. |
|