CMakeInstall.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Define option CMake_TEST_INSTALL, and enable by default for dashboards.
  2. set(_default 0)
  3. if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
  4. set(_default 1)
  5. endif()
  6. option(CMake_TEST_INSTALL "Test CMake Installation" ${_default})
  7. mark_as_advanced(CMake_TEST_INSTALL)
  8. if(CMake_TEST_INSTALL)
  9. # Do not build during the test.
  10. set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
  11. # Install to a test directory.
  12. set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall)
  13. set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}")
  14. # 3.9 or later provides a definitive answer to whether we are multi-config
  15. # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set
  16. # is assumed to mean multi-config, but developers might modify it so it is
  17. # technically not as reliable.
  18. if(NOT CMAKE_VERSION VERSION_LESS 3.9)
  19. get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  20. elseif(CMAKE_CONFIGURATION_TYPES)
  21. set(_isMultiConfig True)
  22. else()
  23. set(_isMultiConfig False)
  24. endif()
  25. if(_isMultiConfig)
  26. # There are multiple configurations. Make sure the tested
  27. # configuration is the one that is installed.
  28. set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>)
  29. else()
  30. set(CMake_TEST_INSTALL_CONFIG)
  31. endif()
  32. # Add a test to install CMake through the build system install target.
  33. add_test(NAME CMake.Install
  34. COMMAND cmake --build . --target install ${CMake_TEST_INSTALL_CONFIG}
  35. )
  36. # Avoid running this test simultaneously with other tests:
  37. set_tests_properties(CMake.Install PROPERTIES RUN_SERIAL ON)
  38. # TODO: Make all other tests depend on this one, and then drive them
  39. # with the installed CTest.
  40. else()
  41. set(CMake_TEST_INSTALL_PREFIX)
  42. endif()