Currently banging my head against the following.
Am on Windows and have the following working directory:
C:\code\project - windows\build
I then configured a test within the CMakeLists.txt
:
add_test(NAME MyTest
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}\tests.cmd"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
I cannot get this test to work when the working directory has a space in it. If I change the location the code is checked out to i.e:
C:\code\project_windows\build
It works without issue. How can I get CTest to handle a WORKING_DIRECTORY
with a space in it’s path on Windows?
The error I get with WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
is:
1. 'C:/code/project' is not a recognized as an internal or external command'
I then thought it was a simple case of escaping i.e WORKING_DIRECTORY "\"${CMAKE_CURRENT_SOURCE_DIR}\""
, but this then fails as well. It complains about not being able to change into the now escaped working directory i.e "C:\code\project_windows\build"
FWIW I think the error is coming down to this part of the codebase: