CMakeInstall.cmake 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. if(CMAKE_CONFIGURATION_TYPES)
  15. # There are multiple configurations. Make sure the tested
  16. # configuration is the one that is installed.
  17. set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>)
  18. else()
  19. set(CMake_TEST_INSTALL_CONFIG)
  20. endif()
  21. # Add a test to install CMake through the build system install target.
  22. add_test(NAME CMake.Install
  23. COMMAND cmake --build . --target install ${CMake_TEST_INSTALL_CONFIG}
  24. )
  25. # Avoid running this test simultaneously with other tests:
  26. set_tests_properties(CMake.Install PROPERTIES RUN_SERIAL ON)
  27. # TODO: Make all other tests depend on this one, and then drive them
  28. # with the installed CTest.
  29. else()
  30. set(CMake_TEST_INSTALL_PREFIX)
  31. endif()