1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5CTestUseLaunchers 6----------------- 7 8Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on. 9 10CTestUseLaunchers is automatically included when you include(CTest). 11However, it is split out into its own module file so projects can use 12the CTEST_USE_LAUNCHERS functionality independently. 13 14To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S 15dashboard script, and then also set it in the cache of the configured 16project. Both cmake and ctest need to know the value of it for the 17launchers to work properly. CMake needs to know in order to generate 18proper build rules, and ctest, in order to produce the proper error 19and warning analysis. 20 21For convenience, you may set the ENV variable 22CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as 23long as your CMakeLists uses include(CTest) or 24include(CTestUseLaunchers), it will use the value of the ENV variable 25to initialize a CTEST_USE_LAUNCHERS cache variable. This cache 26variable initialization only occurs if CTEST_USE_LAUNCHERS is not 27already defined. 28 29.. versionadded:: 3.8 30 If CTEST_USE_LAUNCHERS is on in a ctest -S script 31 the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE 32 to the cmake command used to configure the project. 33#]=======================================================================] 34 35if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT}) 36 set(CTEST_USE_LAUNCHERS "$ENV{CTEST_USE_LAUNCHERS_DEFAULT}" 37 CACHE INTERNAL "CTEST_USE_LAUNCHERS initial value from ENV") 38endif() 39 40if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") 41 set(CTEST_USE_LAUNCHERS 0) 42endif() 43 44if(CTEST_USE_LAUNCHERS) 45 set(__launch_common_options 46 "--target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR>") 47 48 set(__launch_compile_options 49 "${__launch_common_options} --output <OBJECT> --source <SOURCE> --language <LANGUAGE>") 50 51 set(__launch_link_options 52 "${__launch_common_options} --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE>") 53 54 set(__launch_custom_options 55 "${__launch_common_options} --output <OUTPUT>") 56 57 if("${CMAKE_GENERATOR}" MATCHES "Ninja") 58 string(APPEND __launch_compile_options " --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>") 59 endif() 60 61 set(CTEST_LAUNCH_COMPILE 62 "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_compile_options} --") 63 64 set(CTEST_LAUNCH_LINK 65 "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_link_options} --") 66 67 set(CTEST_LAUNCH_CUSTOM 68 "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_custom_options} --") 69 70 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CTEST_LAUNCH_COMPILE}") 71 set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CTEST_LAUNCH_LINK}") 72 set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CTEST_LAUNCH_CUSTOM}") 73endif() 74