diff options
Diffstat (limited to 'Tests/RunCMake/install')
43 files changed, 225 insertions, 1 deletions
diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..c14998e --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^dir;dir/empty.txt$]]) diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake new file mode 100644 index 0000000..e57aab0 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake @@ -0,0 +1 @@ +install(DIRECTORY dir/ noexist/ DESTINATION dir OPTIONAL) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake new file mode 100644 index 0000000..7a20edc --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^dir1;dir1/empty\.c;dir1/empty\.h;dir2;dir2/pattern;dir2/pattern/empty\.txt;dir3;dir3/empty\.c;dir3/empty\.h;dir3/empty\.txt;dir4;dir4/empty\.c;dir4/empty\.h;dir4/empty\.txt;empty$]]) diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake new file mode 100644 index 0000000..74d8043 --- /dev/null +++ b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake @@ -0,0 +1,36 @@ +install( + DIRECTORY pattern/ + DESTINATION dir1 + FILES_MATCHING + PATTERN "*.h" + REGEX "\\.c$" + ) + +# FIXME: If/when CMake gains a good way to read file permissions, we should +# check that these permissions were set correctly. +install( + DIRECTORY pattern + DESTINATION dir2 + FILE_PERMISSIONS OWNER_READ OWNER_WRITE + DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + PATTERN "*.h" EXCLUDE + REGEX "\\.c$" EXCLUDE + ) + +install( + DIRECTORY pattern/ + DESTINATION dir3 + PATTERN "*.h" + PERMISSIONS OWNER_READ OWNER_WRITE + ) + +install( + DIRECTORY pattern/ + DESTINATION dir4 + USE_SOURCE_PERMISSIONS + ) + +install( + DIRECTORY + DESTINATION empty + ) diff --git a/Tests/RunCMake/install/Deprecated-all-check.cmake b/Tests/RunCMake/install/Deprecated-all-check.cmake new file mode 100644 index 0000000..9ea33a6 --- /dev/null +++ b/Tests/RunCMake/install/Deprecated-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?;scripts1;scripts1/script;scripts1/script\.bat;scripts2;scripts2/script;scripts2/script\.bat;scripts3;scripts3/script;scripts3/script\.bat;src;src/empty\.c;src/obj1\.c;src/obj\2.c$]]) diff --git a/Tests/RunCMake/install/Deprecated.cmake b/Tests/RunCMake/install/Deprecated.cmake new file mode 100644 index 0000000..c435cb5 --- /dev/null +++ b/Tests/RunCMake/install/Deprecated.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +add_executable(myexe main.c) + +install_files(/src FILES empty.c) +install_files(/src .c obj1) +install_files(/src "^obj2.c$") + +install_targets(/bin myexe) + +install_programs(/scripts1 FILES script script.bat) +install_programs(/scripts2 script script.bat) +install_programs(/scripts3 "^script(\.bat)?$") diff --git a/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..2997a8d --- /dev/null +++ b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/main.c$]]) diff --git a/Tests/RunCMake/install/FILES-OPTIONAL.cmake b/Tests/RunCMake/install/FILES-OPTIONAL.cmake new file mode 100644 index 0000000..812bf4f --- /dev/null +++ b/Tests/RunCMake/install/FILES-OPTIONAL.cmake @@ -0,0 +1 @@ +install(FILES main.c noexist.c DESTINATION src OPTIONAL) diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake new file mode 100644 index 0000000..b8ba6d0 --- /dev/null +++ b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/empty.c]]) diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake new file mode 100644 index 0000000..999c271 --- /dev/null +++ b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake @@ -0,0 +1,5 @@ +install( + FILES empty.c + DESTINATION src + PERMISSIONS OWNER_READ OWNER_WRITE + ) diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake new file mode 100644 index 0000000..27ff683 --- /dev/null +++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake @@ -0,0 +1,10 @@ +enable_language(C) +set(CMAKE_INSTALL_MFC_LIBRARIES 1) +set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +set(CMAKE_INSTALL_UCRT_LIBRARIES 1) +set(CMAKE_INSTALL_OPENMP_LIBRARIES 1) +include(InstallRequiredSystemLibraries) + +# FIXME: This test emits warnings because InstallRequiredSystemLibraries +# doesn't currently work properly. The warnings have been suppressed in +# InstallRequiredSystemLibraries-stderr.txt. This needs to be fixed. diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake new file mode 100644 index 0000000..16ff1e1 --- /dev/null +++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?;postinstall;preinstall]]) diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake new file mode 100644 index 0000000..357c688 --- /dev/null +++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(myexe main.c) +set_property(TARGET myexe PROPERTY PRE_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/preinstall.cmake") +set_property(TARGET myexe PROPERTY POST_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/postinstall.cmake") + +install(TARGETS myexe DESTINATION bin) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index b1add3a..91524a6 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -73,8 +73,26 @@ if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES} endif() run_install_test(TARGETS-InstallFromSubDir) +run_install_test(TARGETS-OPTIONAL) +run_install_test(FILES-OPTIONAL) +run_install_test(DIRECTORY-OPTIONAL) + +set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug") +run_install_test(TARGETS-OUTPUT_NAME) +unset(RunCMake_TEST_OPTIONS) + +run_install_test(Deprecated) +run_install_test(PRE_POST_INSTALL_SCRIPT) +run_install_test(SCRIPT) +run_install_test(TARGETS-CONFIGURATIONS) +run_install_test(DIRECTORY-PATTERN) +run_install_test(TARGETS-Parts) +run_install_test(FILES-PERMISSIONS) +run_install_test(TARGETS-RPATH) +run_install_test(InstallRequiredSystemLibraries) set(run_install_test_components 1) run_install_test(FILES-EXCLUDE_FROM_ALL) run_install_test(TARGETS-EXCLUDE_FROM_ALL) run_install_test(TARGETS-NAMELINK_COMPONENT) +run_install_test(SCRIPT-COMPONENT) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake new file mode 100644 index 0000000..e09a102 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^$]]) diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake new file mode 100644 index 0000000..aaa9bd4 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake @@ -0,0 +1,5 @@ +install( + SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + CODE "write_empty_file(empty2.txt)" + COMPONENT dev + ) diff --git a/Tests/RunCMake/install/SCRIPT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-all-check.cmake new file mode 100644 index 0000000..48d8e1a --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^empty1.txt;empty2.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT.cmake b/Tests/RunCMake/install/SCRIPT.cmake new file mode 100644 index 0000000..f857b54 --- /dev/null +++ b/Tests/RunCMake/install/SCRIPT.cmake @@ -0,0 +1,4 @@ +install( + SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + CODE "write_empty_file(empty2.txt)" + ) diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake new file mode 100644 index 0000000..2866e7f --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src;src/main-d.c$]]) diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake new file mode 100644 index 0000000..5531cd2 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake @@ -0,0 +1,2 @@ +install(FILES main.c DESTINATION src CONFIGURATIONS Debug RENAME main-d.c) +install(FILES main.c DESTINATION src CONFIGURATIONS Release RENAME main-r.c) diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake new file mode 100644 index 0000000..bcf71dd --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin;bin/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt b/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt new file mode 100644 index 0000000..86e3ec0 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL-stderr.txt @@ -0,0 +1 @@ +^WARNING: Target "notall" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it\. CMake does not define behavior for this case\.$ diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake new file mode 100644 index 0000000..d3c5cda --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake @@ -0,0 +1,4 @@ +enable_language(C) +add_executable(myexe main.c) +add_executable(notall EXCLUDE_FROM_ALL main.c) +install(TARGETS myexe notall DESTINATION bin OPTIONAL) diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake new file mode 100644 index 0000000..5daecc8 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake @@ -0,0 +1,13 @@ +if(WIN32) + set(test123 [[bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe]]) + set(libtest45 [[bin/libtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a]]) + set(test45 [[bin/test4\.dll;bin/test4\.lib;bin/test5ar\.lib]]) + + check_installed("^bin;(${libtest45};${test123})|(${test123};${test45})\$") +elseif(CYGWIN) + check_installed([[^bin;bin/cygtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a;bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe$]]) +elseif(APPLE) + check_installed([[^bin;bin/libtest4lib\.dylib;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]]) +else() + check_installed([[^bin;bin/libtest4lib\.so;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]]) +endif() diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake new file mode 100644 index 0000000..67e7069 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake @@ -0,0 +1,27 @@ +enable_language(C) + +add_executable(test1 main.c) +set_property(TARGET test1 PROPERTY OUTPUT_NAME test1out) +set_property(TARGET test1 PROPERTY RELEASE_OUTPUT_NAME test1rel) + +add_executable(test2 main.c) +set_property(TARGET test2 PROPERTY OUTPUT_NAME test2out) +set_property(TARGET test2 PROPERTY DEBUG_OUTPUT_NAME test2deb) + +add_executable(test3 main.c) +set_property(TARGET test3 PROPERTY RUNTIME_OUTPUT_NAME test3exc) + +add_library(test4 SHARED obj1.c) +set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4lib) + +add_library(test5 STATIC obj1.c) +set_property(TARGET test5 PROPERTY ARCHIVE_OUTPUT_NAME test5ar) + +install(TARGETS + test1 + test2 + test3 + test4 + test5 + DESTINATION bin + ) diff --git a/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake new file mode 100644 index 0000000..6245839 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^include;include/obj1\.h;lib;lib/(mylib\.lib|(lib|cyg)mylib\.a)$]]) diff --git a/Tests/RunCMake/install/TARGETS-Parts.cmake b/Tests/RunCMake/install/TARGETS-Parts.cmake new file mode 100644 index 0000000..2a46ab9 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-Parts.cmake @@ -0,0 +1,7 @@ +enable_language(C) +add_library(mylib STATIC obj1.c) +set_property(TARGET mylib PROPERTY PUBLIC_HEADER obj1.h) +install(TARGETS mylib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) diff --git a/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake new file mode 100644 index 0000000..fa52d65 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake @@ -0,0 +1,14 @@ +execute_process( + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/myexe" + RESULT_VARIABLE MYEXE_RESULT + OUTPUT_VARIABLE MYEXE_OUTPUT + ERROR_VARIABLE MYEXE_ERROR + ) + +if(NOT MYEXE_RESULT EQUAL "0") + set(RunCMake_TEST_FAILED "myexe returned [${MYEXE_RESULT}], was expecting [0]") +elseif(NOT MYEXE_OUTPUT STREQUAL "") + set(RunCMake_TEST_FAILED "myexe printed nonempty output:\n${MYEXE_OUTPUT}") +elseif(NOT MYEXE_ERROR STREQUAL "") + set(RunCMake_TEST_FAILED "myexe printed nonempty error:\n${MYEXE_ERROR}") +endif() diff --git a/Tests/RunCMake/install/TARGETS-RPATH.cmake b/Tests/RunCMake/install/TARGETS-RPATH.cmake new file mode 100644 index 0000000..b75deff --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-RPATH.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.9) + +enable_language(C) + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) +add_library(mylib SHARED obj1.c) +add_executable(myexe testobj1.c) +target_link_libraries(myexe mylib) +set_property(TARGET myexe PROPERTY INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/root-all/bin") +set_target_properties(mylib PROPERTIES VERSION 1.0 SOVERSION 1) + +install(TARGETS mylib myexe + DESTINATION bin + ) diff --git a/Tests/RunCMake/install/install_script.cmake b/Tests/RunCMake/install/install_script.cmake new file mode 100644 index 0000000..1f8522c --- /dev/null +++ b/Tests/RunCMake/install/install_script.cmake @@ -0,0 +1,5 @@ +function(write_empty_file FILENAME) + file(WRITE "${CMAKE_INSTALL_PREFIX}/${FILENAME}" "") +endfunction() + +write_empty_file(empty1.txt) diff --git a/Tests/RunCMake/install/obj1.c b/Tests/RunCMake/install/obj1.c index 2411aab..70007df 100644 --- a/Tests/RunCMake/install/obj1.c +++ b/Tests/RunCMake/install/obj1.c @@ -1,4 +1,7 @@ -int obj1(void) +#ifdef _WIN32 +__declspec(dllexport) +#endif + int obj1(void) { return 0; } diff --git a/Tests/RunCMake/install/obj1.h b/Tests/RunCMake/install/obj1.h new file mode 100644 index 0000000..d88d5d2 --- /dev/null +++ b/Tests/RunCMake/install/obj1.h @@ -0,0 +1,6 @@ +#ifndef OBJ1_H +#define OBJ1_H + +int obj1(void); + +#endif /* OBJ1_H */ diff --git a/Tests/RunCMake/install/pattern/empty.c b/Tests/RunCMake/install/pattern/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.c diff --git a/Tests/RunCMake/install/pattern/empty.h b/Tests/RunCMake/install/pattern/empty.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.h diff --git a/Tests/RunCMake/install/pattern/empty.txt b/Tests/RunCMake/install/pattern/empty.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/install/pattern/empty.txt diff --git a/Tests/RunCMake/install/postinstall.cmake b/Tests/RunCMake/install/postinstall.cmake new file mode 100644 index 0000000..7607f40 --- /dev/null +++ b/Tests/RunCMake/install/postinstall.cmake @@ -0,0 +1 @@ +file(WRITE "${CMAKE_INSTALL_PREFIX}/postinstall" "postinstall") diff --git a/Tests/RunCMake/install/preinstall.cmake b/Tests/RunCMake/install/preinstall.cmake new file mode 100644 index 0000000..4b28d16 --- /dev/null +++ b/Tests/RunCMake/install/preinstall.cmake @@ -0,0 +1 @@ +file(WRITE "${CMAKE_INSTALL_PREFIX}/preinstall" "preinstall") diff --git a/Tests/RunCMake/install/script b/Tests/RunCMake/install/script new file mode 100755 index 0000000..81f9f53 --- /dev/null +++ b/Tests/RunCMake/install/script @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Sample Script Output" diff --git a/Tests/RunCMake/install/script.bat b/Tests/RunCMake/install/script.bat new file mode 100755 index 0000000..a9af38c --- /dev/null +++ b/Tests/RunCMake/install/script.bat @@ -0,0 +1 @@ +@echo Sample Script Output diff --git a/Tests/RunCMake/install/testobj1.c b/Tests/RunCMake/install/testobj1.c new file mode 100644 index 0000000..081ef20 --- /dev/null +++ b/Tests/RunCMake/install/testobj1.c @@ -0,0 +1,9 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + int obj1(void); + +int main(void) +{ + return obj1(); +} |