Zachary Pincus wrote:
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?

Use the new EXECUTE_PROCESS command instead.

If you need compatibility with CMake 2.2 and earlier then escape the quotes so they get passed explicitly on the command line"

EXEC_PROGRAM("${PYTHON_EXECUTABLE}"
  ARGS \"${CMAKE_CURRENT_BINARY_DIR}/det_spp.py\"
  OUTPUT_VARIABLE py_spp)

-Brad
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to