CTestUseLaunchers.cmake 2.8 KB

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