summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2021-03-27 22:52:56 (GMT)
committerDomen Vrankar <domen.vrankar@gmail.com>2021-03-28 23:26:58 (GMT)
commitd0adb2386a87046e9236b1b2b4d1c2706c78a711 (patch)
tree00d4809ac2422d6432bb0c5ea99ebf58022490e8
parent699577e7b2ca4e3f987b4a74bb4f88e4cfeff786 (diff)
downloadCMake-d0adb2386a87046e9236b1b2b4d1c2706c78a711.zip
CMake-d0adb2386a87046e9236b1b2b4d1c2706c78a711.tar.gz
CMake-d0adb2386a87046e9236b1b2b4d1c2706c78a711.tar.bz2
CPackRPM: correctly handle empty dir in single package mode
Enabling CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE while having an empty directory in non main component resulted in packaging error that the directory does not exist. Fixes: #21951
-rw-r--r--Modules/Internal/CPack/CPackRPM.cmake10
-rw-r--r--Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake3
3 files changed, 12 insertions, 3 deletions
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index 08bbc68..d853189 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -1349,15 +1349,21 @@ function(cpack_rpm_generate_package)
continue()
endif()
- file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE
+ file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES true RELATIVE
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}"
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*")
foreach(f_ IN LISTS files_for_move_)
- get_filename_component(dir_path_ "${f_}" DIRECTORY)
set(src_file_
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}")
+ if(IS_DIRECTORY "${src_file_}")
+ file(MAKE_DIRECTORY "${WDIR}/${f_}")
+ continue()
+ endif()
+
+ get_filename_component(dir_path_ "${f_}" DIRECTORY)
+
# check that we are not overriding an existing file that doesn't
# match the file that we want to copy
if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}")
diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
index 936e4ed..1dc7084 100644
--- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
@@ -9,7 +9,7 @@ if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL
set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm")
set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm")
- set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so")
+ set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so;/empty_dir")
set(EXPECTED_FILE_4_COMPONENT "debuginfo")
set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*")
diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake
index 60e9038..064539e 100644
--- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake
+++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake
@@ -30,6 +30,9 @@ if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo")
install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
install(TARGETS test_lib DESTINATION bas COMPONENT libs)
+
+ # test that we correctly handle empty dir in non main component
+ install(DIRECTORY DESTINATION empty_dir COMPONENT libs)
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component"
OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo")
set(CPACK_COMPONENTS_ALL applications)