diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2020-06-02 18:10:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-15 15:06:41 (GMT) |
commit | 915409af490c253924acbb58ea97c809ff8e631c (patch) | |
tree | 361dac354f64a1aa63667f577f33765c58fb2a94 /Tests/RunCMake/CPack | |
parent | 43b10e2411858ae7734c54480a8c0c6c3ccd659b (diff) | |
download | CMake-915409af490c253924acbb58ea97c809ff8e631c.zip CMake-915409af490c253924acbb58ea97c809ff8e631c.tar.gz CMake-915409af490c253924acbb58ea97c809ff8e631c.tar.bz2 |
CPack: Introduce pre- and post- build actions
CPack learned the `CPACK_PRE_BUILD_SCRIPTS`, `CPACK_POST_BUILD_SCRIPTS`,
and `CPACK_PACKAGE_FILES` variables.
The first two are lists of scripts to perform
- after pre-install files into a staging directory and before
producing the resulting packages
- after produsing the packages
The post-build script(s) also get the list of actually produced
packages in the `CPACK_PACKAGE_FILES`.
Issue: #19077
Diffstat (limited to 'Tests/RunCMake/CPack')
7 files changed, 40 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 064b4dc..831f430 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -46,3 +46,4 @@ run_cpack_test_subtests( "MONOLITHIC;COMPONENT" ) run_cpack_test(PROJECT_META "RPM.PROJECT_META;DEB.PROJECT_META" false "MONOLITHIC;COMPONENT") +run_cpack_test_package_target(PRE_POST_SCRIPTS "ZIP" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake new file mode 100644 index 0000000..63a36a3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ExpectedFiles.cmake @@ -0,0 +1,19 @@ +set(SATU "/satu;/satu/CMakeLists.txt") +set(DUA "/dua;/dua/CMakeLists.txt") + +if(GENERATOR_TYPE STREQUAL ZIP) + set(_ext "zip") +elseif(GENERATOR_TYPE STREQUAL TGZ) + set(_ext "tar.gz") +endif() + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "*-satu.${_ext}") + set(EXPECTED_FILE_CONTENT_1_LIST ${SATU}) + set(EXPECTED_FILE_2 "*-dua.${_ext}") + set(EXPECTED_FILE_CONTENT_2_LIST ${DUA}) +else() + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST ${SATU} ${DUA}) +endif() diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt new file mode 100644 index 0000000..319d0da --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_COMPONENT-stdout.txt @@ -0,0 +1,4 @@ +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre\.cmake and generator ZIP +.* +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post\.cmake and generator ZIP +-- Built packages: .*/_CPack_Packages/.*/pre_post_scripts-.*-dua.zip;.*/_CPack_Packages/.*/pre_post_scripts-.*-satu.zip diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt new file mode 100644 index 0000000..632c4d1 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/ZIP_MONOLITHIC-stdout.txt @@ -0,0 +1,4 @@ +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre\.cmake and generator ZIP +.* +-- The message from .*/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post\.cmake and generator ZIP +-- Built packages: .*/_CPack_Packages/.*/pre_post_scripts-0\.1\.1-.*\.zip diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake new file mode 100644 index 0000000..cf0b149 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/post.cmake @@ -0,0 +1,2 @@ +message(STATUS "The message from ${CMAKE_CURRENT_LIST_FILE} and generator ${CPACK_GENERATOR}") +message(STATUS "Built packages: ${CPACK_PACKAGE_FILES}") diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake new file mode 100644 index 0000000..b04aa6b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/pre.cmake @@ -0,0 +1 @@ +message(STATUS "The message from ${CMAKE_CURRENT_LIST_FILE} and generator ${CPACK_GENERATOR}") diff --git a/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake new file mode 100644 index 0000000..f1b6d5f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PRE_POST_SCRIPTS/test.cmake @@ -0,0 +1,9 @@ +install(FILES CMakeLists.txt DESTINATION satu COMPONENT satu) +install(FILES CMakeLists.txt DESTINATION dua COMPONENT dua) + +set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/pre.cmake") +set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/post.cmake") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL satu dua) +endif() |