2016-02-03 22:10:55 +03:00
|
|
|
cmake_minimum_required(VERSION 3.4)
|
2013-12-25 20:59:24 +04:00
|
|
|
include(RunCMake)
|
2016-02-03 22:10:55 +03:00
|
|
|
|
|
|
|
# Function to build and install a project. The latter step *-check.cmake
|
|
|
|
# scripts can check installed files using the check_installed function.
|
|
|
|
function(run_install_test case)
|
|
|
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
|
|
|
|
set(RunCMake_TEST_NO_CLEAN 1)
|
|
|
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
|
|
|
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
|
|
|
run_cmake(${case})
|
|
|
|
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug)
|
|
|
|
# Check "all" components.
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-all)
|
|
|
|
run_cmake_command(${case}-all ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake)
|
|
|
|
# Check unspecified component.
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-uns)
|
|
|
|
run_cmake_command(${case}-uns ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=Unspecified -P cmake_install.cmake)
|
|
|
|
# Check explicit component.
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-exc)
|
|
|
|
run_cmake_command(${case}-exc ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=exc -P cmake_install.cmake)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Function called in *-check.cmake scripts to check installed files.
|
|
|
|
function(check_installed expect)
|
|
|
|
file(GLOB_RECURSE actual
|
|
|
|
LIST_DIRECTORIES TRUE
|
|
|
|
RELATIVE ${CMAKE_INSTALL_PREFIX}
|
|
|
|
${CMAKE_INSTALL_PREFIX}/*
|
|
|
|
)
|
|
|
|
if(actual)
|
|
|
|
list(SORT actual)
|
|
|
|
endif()
|
|
|
|
if(NOT "${actual}" MATCHES "${expect}")
|
|
|
|
set(RunCMake_TEST_FAILED "Installed files:
|
|
|
|
${actual}
|
|
|
|
do not match what we expected:
|
|
|
|
${expect}
|
|
|
|
in directory:
|
|
|
|
${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2014-06-24 19:40:26 +04:00
|
|
|
run_cmake(DIRECTORY-MESSAGE_NEVER)
|
|
|
|
run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
|
2014-06-23 21:54:52 +04:00
|
|
|
run_cmake(DIRECTORY-message)
|
2014-06-24 19:18:43 +04:00
|
|
|
run_cmake(DIRECTORY-message-lazy)
|
2013-12-25 20:59:24 +04:00
|
|
|
run_cmake(SkipInstallRulesWarning)
|
|
|
|
run_cmake(SkipInstallRulesNoWarning1)
|
|
|
|
run_cmake(SkipInstallRulesNoWarning2)
|
2016-01-12 23:01:07 +03:00
|
|
|
run_cmake(DIRECTORY-DIRECTORY-bad)
|
2015-09-24 00:15:29 +03:00
|
|
|
run_cmake(DIRECTORY-DESTINATION-bad)
|
2015-09-23 21:41:52 +03:00
|
|
|
run_cmake(FILES-DESTINATION-bad)
|
2015-02-11 22:02:45 +03:00
|
|
|
run_cmake(TARGETS-DESTINATION-bad)
|
2016-02-04 19:45:54 +03:00
|
|
|
run_cmake(EXPORT-OldIFace)
|
2015-05-14 20:08:27 +03:00
|
|
|
run_cmake(CMP0062-OLD)
|
|
|
|
run_cmake(CMP0062-NEW)
|
|
|
|
run_cmake(CMP0062-WARN)
|
2016-02-03 22:10:55 +03:00
|
|
|
|
|
|
|
run_install_test(FILES-EXCLUDE_FROM_ALL)
|
|
|
|
run_install_test(TARGETS-EXCLUDE_FROM_ALL)
|