On 12/14/2010 05:00 PM, Anders Wang Kristensen wrote: > 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
Yes, pass $<CONFIGURATION> as an argument to your test_runner.py and in there do sys.path.insert(0, "path/to/your/package") to adjust the search path. Be prepared for the case where $<CONFIGURATION> is empty. Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake