CMakeInstall.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 -C "\${CTEST_CONFIGURATION_TYPE}")
  18. else()
  19. set(CMake_TEST_INSTALL_CONFIG)
  20. endif()
  21. # The CTest of the CMake used to build this CMake.
  22. if(CMAKE_CTEST_COMMAND)
  23. set(CMake_TEST_INSTALL_CTest ${CMAKE_CTEST_COMMAND})
  24. else()
  25. set(CMake_TEST_INSTALL_CTest ${CMake_BIN_DIR}/ctest)
  26. endif()
  27. # Add a test to install CMake through the build system install target.
  28. add_test(CMake.Install
  29. ${CMake_TEST_INSTALL_CTest}
  30. ${CMake_TEST_INSTALL_CONFIG}
  31. --build-and-test ${CMake_SOURCE_DIR} ${CMake_BINARY_DIR}
  32. --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR
  33. --build-project CMake
  34. --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM
  35. --build-nocmake
  36. --build-noclean
  37. --build-target install)
  38. # Avoid running this test simultaneously with other tests:
  39. set_tests_properties(CMake.Install PROPERTIES RUN_SERIAL ON)
  40. # TODO: Make all other tests depend on this one, and then drive them
  41. # with the installed CTest.
  42. else()
  43. set(CMake_TEST_INSTALL_PREFIX)
  44. endif()