CTestUseLaunchers.cmake 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #.rst:
  2. # CTestUseLaunchers
  3. # -----------------
  4. #
  5. # Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on.
  6. #
  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. #
  11. # To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S
  12. # dashboard script, and then also set it in the cache of the configured
  13. # project. Both cmake and ctest need to know the value of it for the
  14. # launchers to work properly. CMake needs to know in order to generate
  15. # proper build rules, and ctest, in order to produce the proper error
  16. # and warning analysis.
  17. #
  18. # For convenience, you may set the ENV variable
  19. # CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as
  20. # long as your CMakeLists uses include(CTest) or
  21. # include(CTestUseLaunchers), it will use the value of the ENV variable
  22. # to initialize a CTEST_USE_LAUNCHERS cache variable. This cache
  23. # variable initialization only occurs if CTEST_USE_LAUNCHERS is not
  24. # already defined.
  25. #=============================================================================
  26. # Copyright 2008-2012 Kitware, Inc.
  27. #
  28. # Distributed under the OSI-approved BSD License (the "License");
  29. # see accompanying file Copyright.txt for details.
  30. #
  31. # This software is distributed WITHOUT ANY WARRANTY; without even the
  32. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  33. # See the License for more information.
  34. #=============================================================================
  35. # (To distribute this file outside of CMake, substitute the full
  36. # License text for the above reference.)
  37. if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT})
  38. set(CTEST_USE_LAUNCHERS "$ENV{CTEST_USE_LAUNCHERS_DEFAULT}"
  39. CACHE INTERNAL "CTEST_USE_LAUNCHERS initial value from ENV")
  40. endif()
  41. if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
  42. set(CTEST_USE_LAUNCHERS 0)
  43. endif()
  44. if(CTEST_USE_LAUNCHERS)
  45. set(__launch_common_options
  46. "--target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR>")
  47. set(__launch_compile_options
  48. "${__launch_common_options} --output <OBJECT> --source <SOURCE> --language <LANGUAGE>")
  49. set(__launch_link_options
  50. "${__launch_common_options} --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE>")
  51. set(__launch_custom_options
  52. "${__launch_common_options} --output <OUTPUT>")
  53. if("${CMAKE_GENERATOR}" MATCHES "Ninja")
  54. set(__launch_compile_options "${__launch_compile_options} --filter-prefix <CMAKE_CL_SHOWINCLUDES_PREFIX>")
  55. endif()
  56. set(CTEST_LAUNCH_COMPILE
  57. "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_compile_options} --")
  58. set(CTEST_LAUNCH_LINK
  59. "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_link_options} --")
  60. set(CTEST_LAUNCH_CUSTOM
  61. "\"${CMAKE_CTEST_COMMAND}\" --launch ${__launch_custom_options} --")
  62. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CTEST_LAUNCH_COMPILE}")
  63. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CTEST_LAUNCH_LINK}")
  64. set_property(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CTEST_LAUNCH_CUSTOM}")
  65. endif()