[cmake-developers] can ctest script using CMAKE_CFG_INTDIR ?

comic fans comicfans44 at gmail.com
Wed Jul 5 19:29:10 EDT 2017


I'm running cmake tests on a experimental multi-config fastbuild generator,
for test 106 TargetName:


it has a custom command
  COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/hello_world ${CMAKE_CURRENT_BINARY_DIR}

and in test it compare two files:
    --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
    ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
    ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)

to avoid different config build overwrite output to each
other,(fastbuild is strict and do not allow duplicate output)
I tried to modify copy command as

  COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/hello_world
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/

now build successfully and files copied into different dir,

but when I changed test script as :
    --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
    ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
${CMake_BINARY_DIR}/Tests/TargetName/scripts/${CMAKE_CFG_INTDIR}/hello_world)

the test script will run as:

/home/comicfans/working/CMake/fastbuild/bin/Release/ctest
"--build-and-test" "/home/comicfans/working/CMake/Tests/TargetName"
"/home/comicfans/working/CMake/fastbuild/Tests/TargetName"
"--build-two-config" "--build-generator" "Fastbuild" "--build-project"
"TargetName" "--build-options"
"-DCMAKE_MAKE_PROGRAM:FILEPATH=/home/comicfans/working/fastbuild/tmp/x64Linux-Debug/Tools/FBuild/FBuildApp/fbuild"
"--test-command" "/home/comicfans/working/CMake/fastbuild/bin/cmake"
"-E" "compare_files"
"/home/comicfans/working/CMake/Tests/TargetName/scripts/hello_world"
"/home/comicfans/working/CMake/fastbuild/Tests/TargetName/scripts/FASTBUILD_DOLLAR_TAGConfigNameFASTBUILD_DOLLAR_TAG/hello_world"


FASTBUILD_DOLLAR_TAGConfigNameFASTBUILD_DOLLAR_TAG
is the place holder string of generator's GetCMakeCFGIntDir returned.
so seems this variable didn't expand with build config, I wonder if
this is problem of generator code(forgot to expand it in some places)
, or CMAKE_CFG_INTDIR variable just didn't expanded during ctest ?
and how can I makes this test script fits multi-config generator?


More information about the cmake-developers mailing list