diff options
author | Brad King <brad.king@kitware.com> | 2017-01-10 14:34:55 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-01-10 14:34:55 (GMT) |
commit | c43cf158d74460440dc5a3d0aec984c754f57958 (patch) | |
tree | 9d5b34bd3690500f2673eba10cf2525ed9e47e27 /Tests/RunCMake/CPack | |
parent | 2c8eb2696a8f3505d45ed5accfa94b3e5541e169 (diff) | |
parent | 36bc7e4c3f91c560df8051afedddea3f49474264 (diff) | |
download | CMake-c43cf158d74460440dc5a3d0aec984c754f57958.zip CMake-c43cf158d74460440dc5a3d0aec984c754f57958.tar.gz CMake-c43cf158d74460440dc5a3d0aec984c754f57958.tar.bz2 |
Merge topic 'cpack-new-tests'
36bc7e4c store old locale to a temporary variable
05c14ea0 RunCMake.CPack_* add COMPONENT to minimal test
5b0a64eb CPack/Archive minimal tests for more formats
Diffstat (limited to 'Tests/RunCMake/CPack')
19 files changed, 109 insertions, 62 deletions
diff --git a/Tests/RunCMake/CPack/7Z/Helpers.cmake b/Tests/RunCMake/CPack/7Z/Helpers.cmake new file mode 100644 index 0000000..f256a42 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "7z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/7Z/Prerequirements.cmake b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/7Z/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake new file mode 100644 index 0000000..ce039f5 --- /dev/null +++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake @@ -0,0 +1,62 @@ +set(ALL_FILES_GLOB "*.${cpack_archive_extension_}") + +function(getPackageContent FILE RESULT_VAR) + # TODO for some types this only works because libarchive handles it... (not + # part of for e.g. gnu tar) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xtf ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} + "${NAME}-${VERSION}-*${COMPONENT}.${cpack_archive_extension_}" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "/$" "" result_ "${i_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + # component and monolithic packages differ for some reason by either having + # package filename prefix in path or not + if(PACKAGING_TYPE STREQUAL "MONOLITHIC") + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".${cpack_archive_extension_}" "/" prefix_ "${prefix_}") + else() + unset(prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index e104866..af44182 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -15,7 +15,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;TGZ" false "MONOLITHIC") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") diff --git a/Tests/RunCMake/CPack/TBZ2/Helpers.cmake b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake new file mode 100644 index 0000000..292b691 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.bz2") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TBZ2/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index 4a194c6..4357a59 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -1,62 +1,3 @@ -set(ALL_FILES_GLOB "*.tar.gz") +set(cpack_archive_extension_ "tar.gz") -function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztvf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) -endfunction() - -function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) - if(COMPONENT) - set(COMPONENT "-${COMPONENT}") - endif() - - set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.tar.gz" PARENT_SCOPE) -endfunction() - -function(getPackageContentList FILE RESULT_VAR) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztf ${FILE} - OUTPUT_VARIABLE package_content_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" package_content_ "${package_content_}") - foreach(i_ IN LISTS package_content_) - string(REGEX REPLACE "/$" "" result_ "${i_}") - list(APPEND items_ "${result_}") - endforeach() - - set(${RESULT_VAR} "${items_}" PARENT_SCOPE) -endfunction() - -function(toExpectedContentList FILE_NO CONTENT_VAR) - findExpectedFile("${FILE_NO}" "file_") - - # component and monolithic packages differ for some reason by either having - # package filename prefix in path or not - if(PACKAGING_TYPE STREQUAL "MONOLITHIC") - get_filename_component(prefix_ "${file_}" NAME) - # NAME_WE removes everything after the dot and dot is in version so replace instead - string(REPLACE ".tar.gz" "/" prefix_ "${prefix_}") - else() - unset(prefix_) - endif() - - if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) - set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") - endif() - - unset(filtered_) - foreach(part_ IN LISTS ${CONTENT_VAR}) - string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") - - if(part_) - list(APPEND filtered_ "${prefix_}${part_}") - endif() - endforeach() - - set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) -endfunction() +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Helpers.cmake b/Tests/RunCMake/CPack/TXZ/Helpers.cmake new file mode 100644 index 0000000..f390cb4 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.xz") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TXZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/TZ/Helpers.cmake b/Tests/RunCMake/CPack/TZ/Helpers.cmake new file mode 100644 index 0000000..117cd24 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "tar.Z") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/TZ/Prerequirements.cmake b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/TZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/ZIP/Helpers.cmake b/Tests/RunCMake/CPack/ZIP/Helpers.cmake new file mode 100644 index 0000000..3710bcf --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Helpers.cmake @@ -0,0 +1,3 @@ +set(cpack_archive_extension_ "zip") + +include("${CMAKE_CURRENT_LIST_DIR}/../ArchiveCommon/common_helpers.cmake") diff --git a/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake new file mode 100644 index 0000000..dbaf682 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/Prerequirements.cmake @@ -0,0 +1,4 @@ +function(get_test_prerequirements found_var config_file) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/ZIP/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake index 83ed0f2..15c5892 100644 --- a/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake +++ b/Tests/RunCMake/CPack/tests/MINIMAL/test.cmake @@ -1 +1,5 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() |