diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2019-11-10 12:20:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-12-09 22:06:10 (GMT) |
commit | 3476dbe6d76aee7409796e3dfd1da6a0c15e7b21 (patch) | |
tree | 54603d78864a7db7802090b5a02235a26a7554a9 | |
parent | a9c09599002baa27bdf4f98664829a92ba529240 (diff) | |
download | CMake-3476dbe6d76aee7409796e3dfd1da6a0c15e7b21.zip CMake-3476dbe6d76aee7409796e3dfd1da6a0c15e7b21.tar.gz CMake-3476dbe6d76aee7409796e3dfd1da6a0c15e7b21.tar.bz2 |
CPack: CMAKE_PROJECT_HOMEPAGE_URL -> CPACK_PACKAGE_HOMEPAGE_URL
At CPack running time the `CMAKE_PROJECT_HOMEPAGE_URL` variable
is not set.
Internal CPack modules (e.g. CPackDEB, CPackRPM, CPackFreeBSD)
should use `CPACK_PACKAGE_HOMEPAGE_URL` instead, which is available
after inclusion of `CPack.cmake` into `CMakeLists.txt`.
Closes: #19607
-rw-r--r-- | Modules/Internal/CPack/CPackDeb.cmake | 4 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackFreeBSD.cmake | 2 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackRPM.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake | 9 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake | 30 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake | 11 |
8 files changed, 58 insertions, 5 deletions
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index ad8e078..fe0fe09 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -546,8 +546,8 @@ function(cpack_deb_prepare_package_vars) ) # Homepage: (optional) - if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CMAKE_PROJECT_HOMEPAGE_URL) - set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CMAKE_PROJECT_HOMEPAGE_URL}") + if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CPACK_PACKAGE_HOMEPAGE_URL) + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_PACKAGE_HOMEPAGE_URL}") endif() # Section: (recommended) diff --git a/Modules/Internal/CPack/CPackFreeBSD.cmake b/Modules/Internal/CPack/CPackFreeBSD.cmake index 16f906c..ae40532 100644 --- a/Modules/Internal/CPack/CPackFreeBSD.cmake +++ b/Modules/Internal/CPack/CPackFreeBSD.cmake @@ -68,7 +68,7 @@ _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION" # There's really only one homepage for a project, so # re-use the Debian setting if it's there. _cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW" - "CMAKE_PROJECT_HOMEPAGE_URL" + "CPACK_PACKAGE_HOMEPAGE_URL" "CPACK_DEBIAN_PACKAGE_HOMEPAGE" "_cpack_freebsd_fallback_www" ) diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index ffb24e2..3485e7d 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -844,8 +844,8 @@ function(cpack_rpm_generate_package) endif() endif() - if(NOT CPACK_RPM_PACKAGE_URL AND CMAKE_PROJECT_HOMEPAGE_URL) - set(CPACK_RPM_PACKAGE_URL "${CMAKE_PROJECT_HOMEPAGE_URL}") + if(NOT CPACK_RPM_PACKAGE_URL AND CPACK_PACKAGE_HOMEPAGE_URL) + set(CPACK_RPM_PACKAGE_URL "${CPACK_PACKAGE_HOMEPAGE_URL}") endif() # CPACK_RPM_PACKAGE_NAME (mandatory) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0a090a8..1e485c4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -553,6 +553,7 @@ set(cpack_tests DEB.MD5SUMS DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY DEB.DEB_DESCRIPTION + DEB.PROJECT_META RPM.CUSTOM_BINARY_SPEC_FILE RPM.CUSTOM_NAMES @@ -573,6 +574,7 @@ set(cpack_tests RPM.SUGGESTS RPM.SYMLINKS RPM.USER_FILELIST + RPM.PROJECT_META 7Z TBZ2 diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index b0b7a99..5fce32a 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -46,3 +46,4 @@ run_cpack_test_subtests( false "MONOLITHIC;COMPONENT" ) +run_cpack_test(PROJECT_META "RPM.PROJECT_META;DEB.PROJECT_META" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake new file mode 100644 index 0000000..448ed2b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/ExpectedFiles.cmake @@ -0,0 +1,9 @@ +if(GENERATOR_TYPE STREQUAL DEB) + set(EXPECTED_FILE_1 "project_meta-1.2.3*.deb") +elseif(GENERATOR_TYPE STREQUAL RPM) + set(EXPECTED_FILE_1 "project_meta-1.2.3*.rpm") +else() + message(FATAL_ERROR "Unexpected CPack generator") +endif() +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake new file mode 100644 index 0000000..b3accb5 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/VerifyResult.cmake @@ -0,0 +1,30 @@ +function(checkPackageURL FILE TAG EXPECTED_URL) + getPackageInfo("${FILE}" "_file_info") + string(REPLACE "\n" ";" _file_info "${_file_info}") + + set(_seen_url FALSE) + foreach(_line IN LISTS _file_info) + if(_line MATCHES "${TAG}: (.*)") + set(_seen_url TRUE) + if(NOT CMAKE_MATCH_1 STREQUAL EXPECTED_URL) + message(FATAL_ERROR "Unexpected `Homepage` URL: `${CMAKE_MATCH_1}` != `${EXPECTED_URL}`") + endif() + break() + endif() + endforeach() + if(NOT _seen_url) + message(FATAL_ERROR "The packge `${FILE}` do not have URL as expected") + endif() +endfunction() + +if(GENERATOR_TYPE STREQUAL DEB) + set(_tag " Homepage") # NOTE The leading space +elseif(GENERATOR_TYPE STREQUAL RPM) + set(_tag "URL.*") +else() + message(FATAL_ERROR "Unexpected CPack generator") +endif() + +checkPackageURL("${FOUND_FILE_1}" "${_tag}" "https://meta.test.info") + +# kate: indent-width 2; diff --git a/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake b/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake new file mode 100644 index 0000000..9c5266a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PROJECT_META/test.cmake @@ -0,0 +1,11 @@ +project( + MetaInfoTest + VERSION 1.2.3 + DESCRIPTION "This is going to be a summary" + HOMEPAGE_URL "https://meta.test.info" +) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() |