From 77333a92c215bb796c8df8a889118b32f64e38e4 Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Thu, 3 Mar 2011 22:43:31 +0100 Subject: [PATCH 1/2] CPack more robust way to collect files belonging to a component --- Source/CPack/cmCPackGenerator.cxx | 74 +++++++++++++++++++------------ 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 86200c1db..2cc2f341b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -810,7 +810,52 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } + // Remember the list of files before installation + // of the current component (if we are in component install) + const char* InstallPrefix = tempInstallDirectory.c_str(); + std::vector filesBefore; + std::string findExpr(InstallPrefix); + if (componentInstall) + { + cmsys::Glob glB; + findExpr += "/*"; + glB.RecurseOn(); + glB.FindFiles(findExpr); + filesBefore = glB.GetFiles(); + sort(filesBefore.begin(),filesBefore.end()); + } + // do installation int res = mf->ReadListFile(0, installFile.c_str()); + // Now rebuild the list of files after installation + // of the current component (if we are in component install) + if (componentInstall) + { + cmsys::Glob glA; + glA.RecurseOn(); + glA.FindFiles(findExpr); + std::vector filesAfter = glA.GetFiles(); + sort(filesAfter.begin(),filesAfter.end()); + std::vector::iterator diff; + std::vector result(filesAfter.size()); + diff = set_difference ( + filesAfter.begin(),filesAfter.end(), + filesBefore.begin(),filesBefore.end(), + result.begin()); + + std::vector::iterator fit; + std::string localFileName; + // Populate the File field of each component + for (fit=result.begin();fit!=diff;++fit) + { + localFileName = cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); + localFileName = localFileName.substr(localFileName.find('/')+1,std::string::npos); + Components[installComponent].Files.push_back(localFileName); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" + < to component <" + <"<GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (absoluteDestFiles.length()>0) { absoluteDestFiles +=";"; @@ -952,35 +997,6 @@ int cmCPackGenerator::DoPackage() // The files to be installed files = gl.GetFiles(); - // For component installations, determine which files go into which - // components. - if (!this->Components.empty()) - { - std::vector::const_iterator it; - for ( it = files.begin(); it != files.end(); ++ it ) - { - // beware we cannot just use tempDirectory as before - // because some generator will "CPACK_INCLUDE_TOPLEVEL_DIRECTORY" - // we really want "CPACK_TEMPORARY_DIRECTORY" - std::string fileN = - cmSystemTools::RelativePath( - this->GetOption("CPACK_TEMPORARY_DIRECTORY"), it->c_str()); - - // Determine which component we are in. - std::string componentName = fileN.substr(0, fileN.find('/')); - - // Strip off the component part of the path. - fileN = fileN.substr(fileN.find('/')+1, std::string::npos); - - // Add this file to the list of files for the component. - this->Components[componentName].Files.push_back(fileN); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" - < to component <" - <"< Date: Fri, 4 Mar 2011 22:57:37 +0100 Subject: [PATCH 2/2] CPack fix compile error on VS70 and avoid KWStyle warnings --- Source/CPack/cmCPackGenerator.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 2cc2f341b..5f314c6d3 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -24,6 +24,7 @@ #include #include #include // auto_ptr +#include #if defined(__HAIKU__) #include @@ -822,7 +823,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( glB.RecurseOn(); glB.FindFiles(findExpr); filesBefore = glB.GetFiles(); - sort(filesBefore.begin(),filesBefore.end()); + std::sort(filesBefore.begin(),filesBefore.end()); } // do installation int res = mf->ReadListFile(0, installFile.c_str()); @@ -834,10 +835,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( glA.RecurseOn(); glA.FindFiles(findExpr); std::vector filesAfter = glA.GetFiles(); - sort(filesAfter.begin(),filesAfter.end()); + std::sort(filesAfter.begin(),filesAfter.end()); std::vector::iterator diff; std::vector result(filesAfter.size()); - diff = set_difference ( + diff = std::set_difference ( filesAfter.begin(),filesAfter.end(), filesBefore.begin(),filesBefore.end(), result.begin()); @@ -847,8 +848,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // Populate the File field of each component for (fit=result.begin();fit!=diff;++fit) { - localFileName = cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); - localFileName = localFileName.substr(localFileName.find('/')+1,std::string::npos); + localFileName = + cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); + localFileName = + localFileName.substr(localFileName.find('/')+1, + std::string::npos); Components[installComponent].Files.push_back(localFileName); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" < to component <"