CTestTestfile is run without a 'current directory'
I am attempting to run tests which require a subdirectory to be present beside the tests. The tests and CTestTestfile are packaged as a post-install sanity check, so there is no "cmake build directory" in this context.
With the following CTestTestfile:
message("CMAKE_CURRENT_LIST_FILE ${CMAKE_CURRENT_LIST_FILE}")
message("CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}")
message("CMAKE_COMMAND ${CMAKE_COMMAND}")
message("CTEST_COMMAND ${CTEST_COMMAND}")
message("PWD $ENV{PWD}")
message("CD $ENV{CD}")
file(MAKE_DIRECTORY "testDir")
add_test(mytest echo ok)
when I run on Windows I get:
C:\tmp>ctest
Test project C:/tmp
CMAKE_CURRENT_LIST_FILE CTestTestfile.cmake
CMAKE_CURRENT_LIST_DIR
CMAKE_COMMAND
CTEST_COMMAND
PWD
CD
and the directory is created in c:\testDir
instead of c:\tmp\testDir
when I run on ubuntu I get:
CMAKE_CURRENT_LIST_FILE CTestTestfile.cmake
CMAKE_CURRENT_LIST_DIR
CMAKE_COMMAND
CTEST_COMMAND
PWD /home/stephen/dev/src/playground/cmake/test
CD
CMake Error at CTestTestfile.cmake:8 (file):
file problem creating directory: /testDir
Unfortunately, the CD
env var on Windows is not set, so I can't use that as a workaround.