MantisBT - CMake
View Issue Details
0016137CMakeCMakepublic2016-06-07 09:562016-06-10 14:21
Andry81 
 
normalminoralways
closedno change required 
Intel x86Windows7 x64
CMake 3.5.2 
 
0016137: ExternalProject_Add: Can't escape ; character in CMAKE_ARGS
Seems ExternalProject_Add became broken from some time ago. I could not figure out when, but from version 3.5.2 (including 3.5.2-rc1) it does not work anymore.
All ";" characters does replace now by space whenever and not matter how you use the expression.
ExternalProject_Add(MySubProject SOURCE_DIR ${SUBPROJECT_ROOT}
    CMAKE_ARGS
        -DMYPATH=c:/blabla1;c:/blabla1/blabla2;c:/blabla1/blabla3
    INSTALL_COMMAND "" )
I Tried these to workaround it:
1. Quotes around the expression ("-DMYPATH=...")
2. Backlash escaping ("-DMYPATH=...\;...")
3. LIST APPEND instead SET
4. LIST_SEPARATOR in ExternalProject_Add
5. STRING REPLACE ^^ to ;

Nothing works.
No tags attached.
Issue History
2016-06-07 09:56Andry81New Issue
2016-06-07 10:10Brad KingNote Added: 0041140
2016-06-07 10:10Brad KingStatusnew => resolved
2016-06-07 10:10Brad KingResolutionopen => no change required
2016-06-07 10:16Andry81Note Added: 0041141
2016-06-07 10:17Andry81Note Added: 0041142
2016-06-07 10:17Andry81Statusresolved => feedback
2016-06-07 10:17Andry81Resolutionno change required => reopened
2016-06-07 10:28Andry81Note Deleted: 0041142
2016-06-07 10:28Andry81Note Deleted: 0041141
2016-06-07 10:30Andry81Note Added: 0041143
2016-06-07 10:30Andry81Statusfeedback => new
2016-06-07 10:37Brad KingNote Added: 0041144
2016-06-07 10:37Brad KingStatusnew => resolved
2016-06-07 10:37Brad KingResolutionreopened => no change required
2016-06-07 10:42Andry81Note Added: 0041145
2016-06-07 11:00Brad KingNote Added: 0041146
2016-06-07 11:17Andry81Note Added: 0041147
2016-06-07 11:25Brad KingNote Added: 0041148
2016-06-07 11:28Brad KingNote Added: 0041149
2016-06-10 14:21Kitware RobotNote Added: 0041155
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0041140)
Brad King   
2016-06-07 10:10   
Use this:

  CMAKE_ARGS -DMYPATH=c:/blabla1|c:/blabla1/blabla2|c:/blabla1/blabla3
  LIST_SEPARATOR |

The purpose of LIST_SEPARATOR is to work around this limitation of the CMake language.
(0041143)
Andry81   
2016-06-07 10:30   
Seems our build system uses some wrapper over ExternalProject_Add macro and not all arguments passes from wrapper to the cmake command. I'll try to look into this to fix that case. Thx!
(0041144)
Brad King   
2016-06-07 10:37   
$ cmake --version
cmake version 3.6.0-rc1

$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(Issue16137 NONE)
include(ExternalProject)

ExternalProject_Add(MySubProject
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SubProject
  CMAKE_ARGS -DMYPATH=c:/blabla1|c:/blabla1/blabla2|c:/blabla1/blabla3
  LIST_SEPARATOR |
  INSTALL_COMMAND ""
  )

$ cat ../SubProject/CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(IssueSubProject NONE)
message(STATUS "MYPATH='${MYPATH}'")

$ cmake ..
-- Building for: Visual Studio 14 2015
...

$ grep MYPATH MySubProject.vcxproj
"C:\Program Files\CMake\bin\cmake.exe" -DMYPATH=c:/blabla1";"c:/blabla1/blabla2";"c:/blabla1/blabla3 "-GVisual Studio 14 2015" C:/.../SubProject

$ cmake --build . --config Debug
...
  Performing configure step for 'MySubProject'
  -- MYPATH='c:/blabla1;c:/blabla1/blabla2;c:/blabla1/blabla3'
...
(0041145)
Andry81   
2016-06-07 10:42   
Strange output. How can i get this one?
"C:\Program Files\CMake\bin\cmake.exe" "-DMYPATH=c:/blabla1;c:/blabla1/blabla2;c:/blabla1/blabla3" "-GVisual Studio 14 2015" C:/.../SubProject
(0041146)
Brad King   
2016-06-07 11:00   
The commands

   "C:\Program Files\CMake\bin\cmake.exe" "-DMYPATH=c:/blabla1;c:/blabla1/blabla2;c:/blabla1/blabla3" "-GVisual Studio 14 2015" C:/.../SubProject

and

   "C:\Program Files\CMake\bin\cmake.exe" -DMYPATH=c:/blabla1";"c:/blabla1/blabla2";"c:/blabla1/blabla3 "-GVisual Studio 14 2015" C:/.../SubProject

are identical after command line parsing. The details of how the arguments are quoted are not important.
(0041147)
Andry81   
2016-06-07 11:17   
Not in this case:
"C:\Program Files\CMake\bin\cmake.exe" "-DMYPATH=c:/bla bla1;c:/bla bla1/blabla2;c:/bla bla1/blabla3" "-GVisual Studio 14 2015" C:/.../SubProject
(0041148)
Brad King   
2016-06-07 11:25   
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(Issue16137 NONE)
include(ExternalProject)

ExternalProject_Add(MySubProject
  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SubProject
  CMAKE_ARGS "-DMYPATH=c:/bla bla1|c:/bla bla1/blabla2|c:/blabla1/bla bla3"
  LIST_SEPARATOR |
  INSTALL_COMMAND ""
  )

$ cmake ..

$ grep MYPATH MySubProject.vcxproj
"C:\Program Files\CMake\bin\cmake.exe" "-DMYPATH=c:/bla bla1";"c:/bla bla1/blabla2";"c:/blabla1/bla bla3" "-GVisual Studio 14 2015" C:/.../SubProject

$ cmake --build . --config Debug
...
  Performing configure step for 'MySubProject'
  -- MYPATH='c:/bla bla1;c:/bla bla1/blabla2;c:/blabla1/bla bla3'
...
(0041149)
Brad King   
2016-06-07 11:28   
For reference, the strange-looking ";" quoting behavior is specific to the VS IDE generators and is explained here:

  https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmOutputConverter.cxx;hb=v3.6.0-rc1#l814 [^]
(0041155)
Kitware Robot   
2016-06-10 14:21   
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.