CTestUseLaunchers.cmake 2.9 KB

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