CPack: allow packaging of empty directories

This commit is contained in:
Domen Vrankar 2015-09-22 02:08:26 +02:00
parent 47b060aee0
commit b58de9fe2b
15 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,4 @@
cpack-package-empty-dirs
------------------------
* The :module:`CPack` module learned to package empty directories.

View File

@ -367,6 +367,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install directory: " << top << std::endl);
gl.RecurseOn();
gl.SetRecurseListDirs(true);
// gl.SetRecurseThroughSymlinks(false);
if ( !gl.FindFiles(findExpr) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -869,6 +871,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cmsys::Glob glB;
findExpr += "/*";
glB.RecurseOn();
glB.SetRecurseListDirs(true);
glB.FindFiles(findExpr);
filesBefore = glB.GetFiles();
std::sort(filesBefore.begin(),filesBefore.end());
@ -908,6 +911,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
{
cmsys::Glob glA;
glA.RecurseOn();
glA.SetRecurseListDirs(true);
glA.FindFiles(findExpr);
std::vector<std::string> filesAfter = glA.GetFiles();
std::sort(filesAfter.begin(),filesAfter.end());
@ -1074,6 +1078,7 @@ int cmCPackGenerator::DoPackage()
std::string findExpr = tempDirectory;
findExpr += "/*";
gl.RecurseOn();
gl.SetRecurseListDirs(true);
gl.SetRecurseThroughSymlinks(false);
if ( !gl.FindFiles(findExpr) )
{

View File

@ -895,12 +895,33 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
{
// FIXME remove if statement once kwsys SystemTools get support for
// source is directory handling in CopyFileAlways function
if(cmSystemTools::FileIsDirectory(source))
{
return Superclass::MakeDirectory(destination);
}
return Superclass::CopyFileAlways(source, destination);
}
bool cmSystemTools::CopyFileIfDifferent(const char* source,
const char* destination)
{
// FIXME remove if statement once kwsys SystemTools get support for
// source is directory handling in CopyFileIfDifferent function
if(cmSystemTools::FileIsDirectory(source))
{
if(SystemTools::FileExists(destination))
{
return true;
}
else
{
return Superclass::MakeDirectory(destination);
}
}
return Superclass::CopyFileIfDifferent(source, destination);
}

View File

@ -8,5 +8,5 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST}-specif
include("${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake")
endif()
set(CPACK_GENERATOR "${GENERATOR_TYPE}")
set(CPACK_GENERATOR "${GENERATOR_TYPE};TGZ")
include(CPack)

View File

@ -0,0 +1,5 @@
set(CPACK_COMPONENTS_ALL test)
install(DIRECTORY DESTINATION empty
COMPONENT test)
set(CPACK_PACKAGE_NAME "components_empty_dir")

View File

@ -0,0 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "components_empty_dir*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -0,0 +1,2 @@
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL "ON")

View File

@ -0,0 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "empty_dir*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -0,0 +1 @@
set(CPACK_PACKAGE_CONTACT "someone")

View File

@ -0,0 +1,4 @@
install(DIRECTORY DESTINATION empty
COMPONENT test)
set(CPACK_PACKAGE_NAME "empty_dir")

View File

@ -0,0 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "components_empty_dir*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$")

View File

@ -0,0 +1 @@
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/COMPONENTS_EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/components_empty_dir.spec$

View File

@ -0,0 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "empty_dir*.rpm")
set(EXPECTED_FILE_CONTENT_1 "^/usr/empty$")

View File

@ -0,0 +1 @@
^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/EMPTY_DIR-build/_CPack_Packages/.*/RPM/SPECS/empty_dir.spec$

View File

@ -8,3 +8,5 @@ run_cpack_test(MINIMAL "RPM;DEB" false)
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false)
run_cpack_test(DEB_EXTRA "DEB" false)
run_cpack_test(DEPENDENCIES "RPM;DEB" true)
run_cpack_test(EMPTY_DIR "RPM;DEB" true)
run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB" true)