From b0852ebc09eec44041e8aa624ec4bb17bda14dac Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Fri, 6 Mar 2015 20:40:53 +0100 Subject: [PATCH 1/2] CPackWIX: Support patching of root elements. --- Modules/CPackWIX.cmake | 6 ++++-- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 105df96fc..5fe51a641 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -148,8 +148,10 @@ # Currently fragments can be injected into most # Component, File and Directory elements. # -# The special Id ``#PRODUCT`` can be used to inject content -# into the ```` element. +# The following additional special Ids can be used: +# +# * ``#PRODUCT`` for the ```` element. +# * ``#PRODUCTFEATURE`` for the root ```` element. # # The following example illustrates how this works. # diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 4b8daf827..13edde3b8 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -474,6 +474,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.AddAttribute("Title", cpackPackageName); featureDefinitions.AddAttribute("Level", "1"); + this->Patch->ApplyFragment("#PRODUCTFEATURE", featureDefinitions); const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); if(package) From 2e16aff1e2218f042f403971403fe583fc5bec97 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Fri, 6 Mar 2015 14:19:30 +0100 Subject: [PATCH 2/2] CPackWIX: Fix .wixobj output locations and filenames. Preserve all but the last extension when generating .wixobj output filenames from source files and make sure they are unique. Output .wixobj files in cpack staging area instead of the current working directory. --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 13edde3b8..257ce7ae3 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -265,13 +265,30 @@ bool cmCPackWIXGenerator::PackageFilesImpl() AppendUserSuppliedExtraSources(); + std::set usedBaseNames; + std::stringstream objectFiles; for(size_t i = 0; i < this->WixSources.size(); ++i) { std::string const& sourceFilename = this->WixSources[i]; + std::string baseName = + cmSystemTools::GetFilenameWithoutLastExtension(sourceFilename); + + unsigned int counter = 0; + std::string uniqueBaseName = baseName; + + while(usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) + { + std::stringstream tmp; + tmp << baseName << ++counter; + uniqueBaseName = tmp.str(); + } + + usedBaseNames.insert(uniqueBaseName); + std::string objectFilename = - cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; + this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj"; if(!RunCandleCommand(sourceFilename, objectFilename)) {