[CMake] ctest, make test and build config

ross hennessy roscoh at gmail.com
Tue May 18 19:28:18 EDT 2010


>> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}, which as I'm on
>> windows (I don't think this gets set on linux?), evaluates to either
>> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug or
>> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release. So I would like my test to
>> have this information, and how I've tried doing this so far is to
>> supply a parameter to the test eg.
>> ADD_TEST( MyTest MyTest -p \${CMAKE_BUILD_TYPE} )
>
> CMAKE_BUILD_TYPE isn't defined on Windows even at CMake time. Just pass
> ${CMAKE_CFG_INTDIR} to your add_test and you should be good to go.
>

Sorry, when I said I tried a variety of other variables in place of
the CMAKE_BUILD_TYPE, I should have been more explicit!

I've now made a simple cmake script "TestImport.cmake" which all it
contains is -

FILE(WRITE TestOutput.txt "WORKING_DIR = ${WORKING_DIR}" )

I'm then calling ADD_TEST as follows -

ADD_TEST(${TESTNAME} "${CMAKE_COMMAND}" -D
WORKING_DIR=\${CMAKE_CFG_INTDIR} -P
${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}.cmake)

With TESTNAME set to TestImport and I have manually added the
TestImport.cmake script into the working directory. When I run this I
constantly get the output "WORKING_DIR = " in the TestOutput.txt file,
which tells me the variable isn't set? I've checked that the
WORKING_DIR variable works by just setting it to a fixed string "test"
and that got set in the file. So the conclusion I'm making is that at
the time of running the test (building RUN_TESTS) I don't have access
to the following variables -
CMAKE_BUILD_TYPE, CTEST_CONFIGURATION_NAME, CMAKE_CFG_INTDIR,
BUILD_TYPE which are all the variables that I could find mentioned on
the mailing lists. So I figure I'm either missing a crucial variable
name, or I'm going about it the wrong way and for some reason, when
the test is run you don't have access to any of this information?

Thanks, Ross


More information about the CMake mailing list