[CMake] ctest, make test and build config
Bill Hoffman
bill.hoffman at kitware.com
Tue May 18 21:54:30 EDT 2010
On 5/18/2010 7:55 PM, ross hennessy wrote:
>> 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)
>
> I forgot to mention that with CMAKE_CFG_INTDIR I also tried removing
> the \ which was escaping the $ so that CMAKE_CFG_INTDIR was evaluated
> at cmake time to $(OutDir), but then this didn't seem to get set by
> VisualStudio when building the RUN_TESTS target either.
>
See the new COMMAND style call to add_test:
add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]
COMMAND <command> [arg1 [arg2 ...]])
If COMMAND specifies an executable target (created by
add_executable)
it will automatically be replaced by the location of the executable
created at build time. If a CONFIGURATIONS option is given then the
test will be executed only when testing under one of the named
configurations.
Arguments after COMMAND may use "generator expressions" with the
syntax "$<...>". These expressions are evaluted during build system
generation and produce information specific to each generated build
configuration. Valid expressions are:
$<CONFIGURATION> = configuration name
$<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)
$<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)
$<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)
where "tgt" is the name of a target. Target file expressions
produce
a full path, but _DIR and _NAME versions can produce the
directory and
file name components:
$<TARGET_FILE_DIR:tgt>/$<TARGET_FILE_NAME:tgt>
$<TARGET_LINKER_FILE_DIR:tgt>/$<TARGET_LINKER_FILE_NAME:tgt>
$<TARGET_SONAME_FILE_DIR:tgt>/$<TARGET_SONAME_FILE_NAME:tgt>
Example usage:
add_test(NAME mytest
COMMAND testDriver --config $<CONFIGURATION>
--exe $<TARGET_FILE:myexe>)
This creates a test "mytest" whose command runs a testDriver tool
passing the configuration name and the full path to the executable
file produced by target "myexe".
More information about the CMake
mailing list