diff options
author | Andrew Fuller <afuller@teradici.com> | 2020-10-30 02:00:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-16 19:03:07 (GMT) |
commit | c826745f5af81c3b1eb9448a102ca247752aa760 (patch) | |
tree | 64c026c07bdd39b0277b004e94570dd00d3914d3 | |
parent | 01b473b81098e95ac3e6cbf173c78bf02bdf036c (diff) | |
download | CMake-c826745f5af81c3b1eb9448a102ca247752aa760.zip CMake-c826745f5af81c3b1eb9448a102ca247752aa760.tar.gz CMake-c826745f5af81c3b1eb9448a102ca247752aa760.tar.bz2 |
CPack/DEB: Do not crash when asked for debug symbols when there are none
Fixes: #21356
-rw-r--r-- | Modules/Internal/CPack/CPackDeb.cmake | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake | 5 |
4 files changed, 15 insertions, 2 deletions
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 431b074..48d451a 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -768,6 +768,10 @@ function(cpack_deb_prepare_package_vars) set(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DBGSYM_OUTPUT_FILE_NAME}" PARENT_SCOPE) list(JOIN BUILD_IDS " " BUILD_IDS) set(GEN_BUILD_IDS "${BUILD_IDS}" PARENT_SCOPE) + else() + unset(GEN_DBGSYMDIR PARENT_SCOPE) + unset(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME PARENT_SCOPE) + unset(GEN_BUILD_IDS PARENT_SCOPE) endif() endfunction() diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 560e5c1..6f21d87 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -507,7 +507,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")); packageFileNames.push_back(std::move(packageFileName)); - if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE")) { + if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") && + this->GetOption("GEN_DBGSYMDIR")) { cmsys::Glob gl; std::string findExpr(this->GetOption("GEN_DBGSYMDIR")); findExpr += "/*"; diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake index cf2e8ac..cf4aa51 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake @@ -1,6 +1,6 @@ set(whitespaces_ "[\t\n\r ]*") -set(EXPECTED_FILES_COUNT "5") +set(EXPECTED_FILES_COUNT "6") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) if(GENERATOR_TYPE STREQUAL "RPM") @@ -39,3 +39,6 @@ elseif(GENERATOR_TYPE STREQUAL "DEB") set(EXPECTED_FILE_5 "TestDinfo-pkg-libs-dbgsym.ddeb") set(EXPECTED_FILE_CONTENT_5 ".*/usr/lib/debug/.build-id/.*\.debug.*") endif() + +set(EXPECTED_FILE_6 "TestDinfo-pkg*-appheaders.${PKG}") +set(EXPECTED_FILE_CONTENT_6_LIST "/include;/include/test_lib.hpp") diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake index 161a36a..d270005 100644 --- a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake @@ -23,6 +23,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") target_link_libraries(test_prog test_lib) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" DESTINATION include COMPONENT appheaders) install(TARGETS test_prog DESTINATION foo COMPONENT applications) install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) install(TARGETS test_lib DESTINATION bas COMPONENT libs) @@ -40,6 +41,10 @@ set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) set(CPACK_DEBIAN_PACKAGE_NAME "Debuginfo") set(CPACK_DEBIAN_LIBS_DEBUGINFO_PACKAGE ON) +# Test that a component with debug info requested but without any debug info produces none +set(CPACK_RPM_APPHEADERS_DEBUGINFO_PACKAGE ON) +set(CPACK_DEBIAN_APPHEADERS_DEBUGINFO_PACKAGE ON) + # test debuginfo package rename set(CPACK_RPM_DEBUGINFO_FILE_NAME "@cpack_component@-DebugInfoPackage.rpm") |