[CMake] Trouble using CTestCustom.cmake to start a background job on Windows

Dan Kegel dank at kegel.com
Mon Sep 15 14:31:57 EDT 2014


I'd like to use CTestCustom.cmake to start a background job when tests
start, and kill it when tests finish.
Works great on Mac and Linux, but for some reason, on Windows ctest
wants to wait for
the background job to finish before starting the tests.

If I create CTestCustom.cmake containing
  set(CTEST_CUSTOM_PRE_TEST C:/foo/startjob.bat)
and c:/foo/startjob.bat contains
   start /b myjob.exe
   echo Job started.

the job does start, and the echo occurs, but no tests are started
unless I kill myjob.exe :-(

Looking at the cmake source, and using Process Monitor,
I can't quite tell where ctest is waiting for myjob.exe to finish.
If I were a real man, I'd build ctest myself and run it under a
debugger, I guess.

I worked around this by writing a tiny C program that calls CreateProcess
with background-y flags and doesn't wait for the process to end,
but it'd be nice if that wasn't needed.


More information about the CMake mailing list