CTestTargets.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. if(NOT RUN_FROM_CTEST_OR_DART)
  4. message(FATAL_ERROR "Do not include CTestTargets.cmake directly")
  5. endif()
  6. if(NOT PROJECT_BINARY_DIR)
  7. message(FATAL_ERROR "Do not include(CTest) before calling project().")
  8. endif()
  9. # make directories in the binary tree
  10. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary)
  11. get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH)
  12. set(CMAKE_TARGET_PATH ${EXECUTABLE_OUTPUT_PATH})
  13. find_program(CMAKE_CTEST_COMMAND ctest ${CMAKE_HOST_PATH} ${CMAKE_TARGET_PATH})
  14. mark_as_advanced(CMAKE_CTEST_COMMAND)
  15. # Use CTest
  16. # configure files
  17. if(CTEST_NEW_FORMAT)
  18. configure_file(
  19. ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
  20. ${PROJECT_BINARY_DIR}/CTestConfiguration.ini )
  21. else()
  22. configure_file(
  23. ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
  24. ${PROJECT_BINARY_DIR}/DartConfiguration.tcl )
  25. endif()
  26. #
  27. # Section 3:
  28. #
  29. # Custom targets to perform dashboard builds and submissions.
  30. # These should NOT need to be modified from project to project.
  31. #
  32. set(__conf_types "")
  33. get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  34. if(_isMultiConfig)
  35. # We need to pass the configuration type on the test command line.
  36. set(__conf_types -C "${CMAKE_CFG_INTDIR}")
  37. endif()
  38. # Add convenience targets. Do this at most once in case of nested
  39. # projects.
  40. define_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED
  41. BRIEF_DOCS "Internal property used by CTestTargets module."
  42. FULL_DOCS "Set by the CTestTargets module to track addition of testing targets."
  43. )
  44. get_property(_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED)
  45. if(NOT _CTEST_TARGETS_ADDED)
  46. set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
  47. # For all generators add basic testing targets.
  48. foreach(mode Experimental Nightly Continuous NightlyMemoryCheck)
  49. add_custom_target(${mode}
  50. ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
  51. USES_TERMINAL
  52. )
  53. set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "")
  54. set_property(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets")
  55. endforeach()
  56. # For Makefile generators add more granular targets.
  57. if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make)")
  58. # Make targets for Experimental builds
  59. foreach(mode Nightly Experimental Continuous)
  60. foreach(testtype
  61. Start Update Configure Build Test Coverage MemCheck Submit
  62. # missing purify
  63. )
  64. add_custom_target(${mode}${testtype}
  65. ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
  66. USES_TERMINAL
  67. )
  68. set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
  69. set_property(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets")
  70. endforeach()
  71. endforeach()
  72. endif()
  73. # If requested, add an alias that is the equivalent of the built-in "test"
  74. # or "RUN_TESTS" target:
  75. if(CTEST_TEST_TARGET_ALIAS)
  76. add_custom_target(${CTEST_TEST_TARGET_ALIAS}
  77. ${CMAKE_CTEST_COMMAND} ${__conf_types}
  78. USES_TERMINAL
  79. )
  80. endif()
  81. endif()