[CMake] CTest and PYTHONPATH

Anders Wang Kristensen awk.junk at gmail.com
Tue Dec 14 11:00:21 EST 2010


Hi,

I'm having some trouble setting PYTHONPATH in order to test a python
extension module built with cmake.
Currently I do the following:

add_test(NAME py_test COMMAND ${PYTHON_EXECUTABLE}
    ${CMAKE_CURRENT_SOURCE_DIR}/test_runner.py)

if (CMAKE_CONFIGURATION_TYPES)
  set (PY_DIR ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR})
else ()
  set (PY_DIR ${CMAKE_BINARY_DIR}/bin)
endif ()

set_tests_properties(py_test
    PROPERTIES ENVIRONMENT "PYTHONPATH=${PY_DIR}")

The problem is that ${CMAKE_CFG_INTDIR} doesn't get parsed fully, so
PY_DIR expands to ../vs10x64/bin/$(Configuration), which obviously
doesn't work.
Searching this mailing list, I can see that other people have had
trouble with this, but I'm unsure what to do in my case.

Should I use $<CONFIGURATION> and pass arguments to add_test or ... ?

kind regards
Anders


More information about the CMake mailing list