MantisBT - CMake
View Issue Details
0011712CMakeCMakepublic2011-01-17 06:252011-01-31 15:58
Andreas Pakulat 
Brad King 
normalmajoralways
closednot fixable 
CMake-2-8 
CMake 2.8.4CMake 2.8.4 
0011712: add_definitions/COMPILE_DEFINITIONS do not support defines with semicolon
Trying to add a define which has a semicolon in its text results in completely broken compiler commandlines with wrong escaping of arguments.

The attached project shows this, there doesn't seem to be a way to escape the semicolon so that cmake ignores it. CMake always interprets that as a separator
for the list of defines apparently, which then breaks the compile-commandline due to broken quoting.

I tried this with both gnu makefiles and gcc as well as nmake makefiles and cl, with the same results.
No tags attached.
related to 0011660closed Brad King Semicolons escaped badly 
gz tst_sep.tar.gz (378) 2011-01-17 06:25
https://public.kitware.com/Bug/file/3633/tst_sep.tar.gz
Issue History
2011-01-17 06:25Andreas PakulatNew Issue
2011-01-17 06:25Andreas PakulatFile Added: tst_sep.tar.gz
2011-01-17 07:38Brad KingAssigned To => Brad King
2011-01-17 07:38Brad KingStatusnew => assigned
2011-01-17 07:39Brad KingNote Added: 0024737
2011-01-17 07:41Brad KingNote Added: 0024738
2011-01-17 07:45Brad KingRelationship addedrelated to 0011660
2011-01-17 08:25Brad KingNote Added: 0024739
2011-01-17 08:30Brad KingNote Added: 0024740
2011-01-17 09:56Andreas PakulatNote Added: 0024748
2011-01-17 10:02Brad KingNote Added: 0024750
2011-01-17 10:02Brad KingStatusassigned => closed
2011-01-17 10:02Brad KingResolutionopen => not fixable
2011-01-31 15:58David ColeFixed in Version => CMake 2.8.4
2011-01-31 15:58David ColeTarget Version => CMake 2.8.4

Notes
(0024737)
Brad King   
2011-01-17 07:39   
There is a disclaimer about this in the documentation:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:COMPILE_DEFINITIONS [^]
  "Dislaimer: Most native build tools have poor support for escaping certain
   values. CMake has work-arounds for many cases but some values may just not be
   possible to pass correctly."
(0024738)
Brad King   
2011-01-17 07:41   
There are also a bunch of comments about it for our reference here:

  http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/Preprocess/CMakeLists.txt;hb=v2.8.3 [^]

Back when I implemented COMPILE_DEFINITIONS I tried to get every key on the US keyboard to pass through definitions correctly on all supported build systems. Semicolon is basically impossible to do everywhere.

I suggest using configure_file to put the definition directly in a header.
(0024739)
Brad King   
2011-01-17 08:25   
> there doesn't seem to be a way to escape the semicolon so that cmake ignores
it.

Either of these works:

  set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS "PATH_SEP=\"\;\"")

OR

  add_definitions( "-DPATH_SEP=\"\;\"")
(0024740)
Brad King   
2011-01-17 08:30   
Documentation updated to mention known limitations:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c64d1385 [^]
(0024748)
Andreas Pakulat   
2011-01-17 09:56   
Indeed that version does work, should've thought about that earlier :|
(0024750)
Brad King   
2011-01-17 10:02   
Closing as "not fixable" because the semicolon really can't be made to work everywhere. The documentation update is a good "fix" though.