[CMake] setting PYTHONPATH for test

Kris Thielemans kris.f.thielemans at gmail.com
Sat Jul 29 21:22:02 EDT 2017


Hi

 

I'm trying to add to the PYTHONPATH for a test that uses Python. I do that
using set_test_properties. When using the makefile generator, I need to add
${CMAKE_CURRENT_BINARY_DIR}. However, for Visual Studio I also need to add
for instance ${CMAKE_CURRENT_BINARY_DIR}/Release.

My current CMakeLists.txt works only on Windows and when building Release
mode:

 

add_test(${name} "${PYTHON_EXECUTABLE}" ${testfile} )

       set_tests_properties ( ${name} PROPERTIES ENVIRONMENT 

"PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Release\;${CMAKE_CURRENT_BINARY_DIR}
")

 

 

I have 2 problems:

*	How do I figure out which configuration is being used?
$<TARGET_FILE_DIR:target}> doesn't seem to work inside set_test_properties
(it just gets passed verbatim)
*	In most cases, I need to use a colon as path-separator for
PYTHONPATH, but on Windows I need to use a semi-colon when using Anaconda,
but probably not when using Cygwin's python.

 

Any suggestions? (I'm using CMake 3.8 currently but would like to be able to
support (much) older versions)

 

Thanks

Kris

 

PS: In case you're interested, I'm trying to get the CMake build for SWIG
running. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170730/ea321d66/attachment-0001.html>


More information about the CMake mailing list