[CMake] Advanced ctest scripting and CTEST_CONFIGURATION_TYPE

Mike Talbot mtalbot at abingdon.oilfield.slb.com
Thu Jul 20 10:08:00 EDT 2006


Hi,

I have a bunch of tests that are created with something like this:

ADD_TEST(mytest "executable_dir/${CTEST_CONFIGURATION_TYPE}/mytest.exe")

Running these with "ctest -C Debug" or "ctest -C Release" works fine.  
However I want to create a ctest script to build and test my project and 
it looks roughly like this:

SET(CTEST_SITE "mysite")
SET(CTEST_BUILD_NAME "mybuild")
SET(CTEST_SOURCE_DIRECTORY "src_dir")
SET(CTEST_BINARY_DIRECTORY "bin_dir")
SET(CTEST_CMAKE_GENERATOR "Visual Studio 7 .NET 2003")

SET(CTEST_BUILD_CONFIGURATION ${CTEST_CONFIGURATION_TYPE})
MESSAGE("config type = ${CTEST_CONFIGURATION_TYPE}")

CTEST_START(Nightly)
CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}")
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}")

If I run this with "ctest -C Debug -S myscript.ctest" the 
CTEST_CONFIGURATION_TYPE variable is empty and the the Release config is 
built instead (presumably the default) but when the tests run they look 
for the executable in the Debug directory.  Alternatively, if I set both 
CTEST_BUILD_CONFIGURATION and CTEST_CONFIGURATION_TYPE to Debug in the 
script and run as "ctest -S myscript.ctest", the build works correctly, 
but the test fails because CTEST_CONFIGURATION_TYPE is empty when the 
test is run.

The only way I can get this to work as expected is to set 
CTEST_BUILD_CONFIGURATION to Debug in the script and also specify -C 
Debug on the command line.  Is there a way around this or am I doing 
something wrong?

Thanks,
Mike



More information about the CMake mailing list