diff options
author | Brad King <brad.king@kitware.com> | 2016-02-03 19:10:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-02-04 14:47:57 (GMT) |
commit | d321c196a0bfb58ff8a32ed14552d1b78b24cf8a (patch) | |
tree | d999efdc700dd168129d86197b24ced543d6c4d4 /Tests | |
parent | 18ce97c4a20b7da4e11006ad80f17cb55e128db1 (diff) | |
download | CMake-d321c196a0bfb58ff8a32ed14552d1b78b24cf8a.zip CMake-d321c196a0bfb58ff8a32ed14552d1b78b24cf8a.tar.gz CMake-d321c196a0bfb58ff8a32ed14552d1b78b24cf8a.tar.bz2 |
Tests: Add cases for install() command EXCLUDE_FROM_ALL option
Diffstat (limited to 'Tests')
10 files changed, 60 insertions, 0 deletions
diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake new file mode 100644 index 0000000..0368df1 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-all;src-all/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake new file mode 100644 index 0000000..41a816f --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-exc;src-exc/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake new file mode 100644 index 0000000..68a1378 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-all;src-all/main\.c;src-uns;src-uns/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake new file mode 100644 index 0000000..720299b --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake @@ -0,0 +1,3 @@ +install(FILES main.c DESTINATION src-all) +install(FILES main.c DESTINATION src-uns EXCLUDE_FROM_ALL) +install(FILES main.c DESTINATION src-exc EXCLUDE_FROM_ALL COMPONENT exc) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 2c1b29d..4d91f92 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -1,4 +1,46 @@ +cmake_minimum_required(VERSION 3.4) include(RunCMake) + +# 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() + run_cmake(DIRECTORY-MESSAGE_NEVER) run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER) run_cmake(DIRECTORY-message) @@ -13,3 +55,6 @@ run_cmake(TARGETS-DESTINATION-bad) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) + +run_install_test(FILES-EXCLUDE_FROM_ALL) +run_install_test(TARGETS-EXCLUDE_FROM_ALL) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake new file mode 100644 index 0000000..9b538bb --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-all;bin-all/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake new file mode 100644 index 0000000..aef0d27 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-exc;bin-exc/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake new file mode 100644 index 0000000..56fd264 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-all;bin-all/myexe(\.exe)?;bin-uns;bin-uns/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake new file mode 100644 index 0000000..6fb2036 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake @@ -0,0 +1,5 @@ +enable_language(C) +add_executable(myexe main.c) +install(TARGETS myexe DESTINATION bin-all) +install(TARGETS myexe DESTINATION bin-uns EXCLUDE_FROM_ALL) +install(TARGETS myexe DESTINATION bin-exc EXCLUDE_FROM_ALL COMPONENT exc) diff --git a/Tests/RunCMake/install/main.c b/Tests/RunCMake/install/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/RunCMake/install/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } |