CTestTargets.cmake 3.5 KB

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