[cmake-developers] [CMake 0015927]: Escape semicolon "; " in CMake/CTest variables?

Mantis Bug Tracker mantis at public.kitware.com
Tue Jan 19 10:07:24 EST 2016


The following issue has been SUBMITTED. 
====================================================================== 
https://public.kitware.com/Bug/view.php?id=15927 
====================================================================== 
Reported By:                Gehua Yang
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15927
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2016-01-19 10:07 EST
Last Modified:              2016-01-19 10:07 EST
====================================================================== 
Summary:                    Escape semicolon ";" in CMake/CTest variables?
Description: 
My CMake-Controlled private build depends on a couple external libraries.  On
Windows, the build needs to find the dll  files of external libraries in order
to run the automated tests.   The solution I came up with is to add those
folders to the PATH environment variable for the build.  Here is what I did in
the CTest script (using CMake 3.4.1 for Windows):

SET(MYPATH
"$ENV{PATH}\;C:\\Gehua\\Code\\tbb\\tbb43_20150611oss\\bin\\intel64\\vc14")
# set any extra envionment variables here
#   a. TBB path is needed to run tests
#   b. Use the "true" command-line plink for git's ssh use.
SET (CTEST_ENVIRONMENT
  "GIT_SSH=c:\\Program Files (x86)\\PuTTY\\plink.exe"
  "PATH=${MYPATH}"
  )
MESSAGE(STATUS "env=${CTEST_ENVIRONMENT}")

Here is the output from running the build from the code above:

-- env=GIT_SSH=c:\Program Files
(x86)\PuTTY\plink.exe;PATH=C:\ProgramData\Oracle\Java\javapath;C:\Program
Files\Broadcom\Broadcom 802.11 Network Adapter;C:\Program Files (x86)\Intel\iCLS
Client\;C:\Program Files\Intel\iCLS
Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;%USERPROFILE%\.dnx\bin;C:\Program
Files (x86)\Skype\Phone\;C:\Program Files\IDM Computer
Solutions\UltraCompare;C:\Program Files\IDM Computer
Solutions\UltraFinder\\;C:\Gehua\Code\tbb\tbb43_20150611oss\bin\intel64\vc14


But this change does NOT work for the tests.  The tests failed without
execution.  I suspected that it still did not find the depending dll files.  So
I added the following code in a simple test file:

  std::cout << "env PATH=" << getenv ("PATH") << '\n';
  std::cout << "env GIT_SSH=" << getenv ("GIT_SSH") << '\n';

The output is :

env PATH=C:\ProgramData\Oracle\Java\javapath
env GIT_SSH=c:\Program Files (x86)\PuTTY\plink.exe


As one can see, The PATH variable content was truncated at the semicolon mark
(";").  It is not surprising outcome as CMake use semicolon as delimiter of list
elements.  But in this particular case,  I am seeking for a way to escape the
semicolons so that CMake/CTest treats it as an integral part of the string.  Is
there a way to do it? 

Steps to Reproduce: 
SET(MYPATH
"$ENV{PATH}\;C:\\Gehua\\Code\\tbb\\tbb43_20150611oss\\bin\\intel64\\vc14")
# set any extra envionment variables here
#   a. TBB path is needed to run tests
#   b. Use the "true" command-line plink for git's ssh use.
SET (CTEST_ENVIRONMENT
  "GIT_SSH=c:\\Program Files (x86)\\PuTTY\\plink.exe"
  "PATH=${MYPATH}"
  )
MESSAGE(STATUS "env=${CTEST_ENVIRONMENT}")


But the result is:
PATH=C:\ProgramData\Oracle\Java\javapath
GIT_SSH=c:\Program Files (x86)\PuTTY\plink.exe
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-01-19 10:07 Gehua Yang     New Issue                                    
======================================================================



More information about the cmake-developers mailing list