set_tests_properties ENVIRONMENT ignored

Rob Stewart
Sat, 18 Jan 2025 00:55:29 +0000
Code

In my CMakeLists.txt, I define a Python unit test like this:

ADD_TEST(NAME foo
   COMMAND "${python}" -B -m unittest discover -v
   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

For that to work, a related .pyd must be found from the binary tree. Thus, I specify PYTHONPATH and another needed environment variable, like this:

SET_TESTS_PROPERTIES(foo PROPERTIES
   ENVIRONMENT "PYTHONPATH=dir1\;dir2;EVAR=false"
)

The Python unit tests run, but the PYTHONPATH doesn’t reflect what I set. I tried forward and backslashes in the path, just in case those mattered.

FYI, I’m using the “Visual Studio 15 2017” generator.

What am I missing?

2 posts - 1 participant