[CMake] Escape/quote spaces in ARGS of EXEC_PROGRAM?

Zachary Pincus zpincus at stanford.edu
Tue Feb 28 04:09:09 EST 2006


Hi folks,

I'm trying to run a program via EXEC_PROGRAM, where one of the  
arguments contains ${CMAKE_CURRENT_BINARY_DIRECTORY}, which may of  
course contain spaces or other characters that need escaping or quoting.

Here's what the cmake block looks like (it's trying to learn the site- 
packages directory from python).

IF(PYTHON_EXECUTABLE)
   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/det_spp.py "try:\n  import  
distutils.sysconfig; print distutils.sysconfig.get_python_lib() 
\nexcept: pass")
   EXEC_PROGRAM("${PYTHON_EXECUTABLE}"
     ARGS "${CMAKE_CURRENT_BINARY_DIR}/det_spp.py"
     OUTPUT_VARIABLE py_spp)
ENDIF(PYTHON_EXECUTABLE)

Right now (using a CMake CVS checkout from yesterday) this fails when  
the path to the current binary dir has spaces in it. Is there  
anything I can do?

Zach


More information about the CMake mailing list