Re: [CMake] setting PYTHONPATH for test

2017-07-30 Thread Nils Gladitz

On 30.07.2017 03:22, Kris Thielemans wrote:


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?
$ doesn’t seem to work inside
set_test_properties (it just gets passed verbatim)



Try using the NAME/COMMAND signature of add_test() e.g.
add_test(NAME ${name} COMMAND “${PYTHON_EXECUTABLE}" ${testfile})

It should enable generator expression processing in test properties.

Nils
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] setting PYTHONPATH for test

2017-07-29 Thread Kris Thielemans
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?
$ 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. 

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake