From 096591b96a0fb8cac2b330bc727c96ff90fa8d97 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sun, 10 Nov 2013 19:48:29 +0100 Subject: CPackWiX: Add variables for custom tool extensions and flags --- Modules/CPackWIX.cmake | 24 ++++++++++- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 69 +++++++++++++++++++++++++++++--- Source/CPack/WiX/cmCPackWIXGenerator.h | 10 +++++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index f4fcf6a..3f0978d 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -123,9 +123,31 @@ # This variable provides an optional list of extra WiX object (.wixobj) # and/or WiX library (.wixlib) files. The full path to objects and libraries # is required. +# +# .. variable:: CPACK_WIX_EXTENSIONS +# +# This variable provides a list of additional extensions for the WiX +# tools light and candle. +# +# .. variable:: CPACK_WIX__EXTENSIONS +# +# This is the tool specific version of CPACK_WIX_EXTENSIONS. +# ```` can be either LIGHT or CANDLE. +# +# .. variable:: CPACK_WIX__EXTRA_FLAGS +# +# This list variable allows you to pass additional +# flags to the WiX tool ````. +# +# Use it at your own risk. +# Future versions of CPack may generate flags which may be in conflict +# with your own flags. +# +# ```` can be either LIGHT or CANDLE. +# #============================================================================= -# Copyright 2012 Kitware, Inc. +# Copyright 2013 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 448d8d1..1d7681b 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -83,6 +83,15 @@ bool cmCPackWIXGenerator::RunCandleCommand( command << " -nologo"; command << " -arch " << GetArchitecture(); command << " -out " << QuotePath(objectFile); + + for(extension_set_t::const_iterator i = candleExtensions.begin(); + i != candleExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + + AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command); + command << " " << QuotePath(sourceFile); return RunWiXCommand(command.str()); @@ -100,12 +109,21 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << QuotePath(executable); command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - command << " -ext WixUIExtension"; + + for(extension_set_t::const_iterator i = lightExtensions.begin(); + i != lightExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + const char* const cultures = GetOption("CPACK_WIX_CULTURES"); if(cultures) { command << " -cultures:" << cultures; } + + AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command); + command << " " << objectFiles; return RunWiXCommand(command.str()); @@ -172,14 +190,21 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() if(GetOption("CPACK_PACKAGE_VENDOR") == 0) { - std::string defaultVendor = "Humanity"; - SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str()); + std::string defaultVendor = "Humanity"; + SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str()); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, - "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . " - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . " + << std::endl); } + CollectExtensions("CPACK_WIX_EXTENSIONS", candleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", candleExtensions); + + lightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); + return true; } @@ -865,3 +890,35 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c) (c >= 'A' && c <= 'Z') || c == '_' || c == '.'; } + +void cmCPackWIXGenerator::CollectExtensions( + const std::string& variableName, extension_set_t& extensions) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector::const_iterator i = list.begin(); + i != list.end(); ++i) + { + extensions.insert(*i); + } +} + +void cmCPackWIXGenerator::AddCustomFlags( + const std::string& variableName, std::ostream& stream) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector::const_iterator i = list.begin(); + i != list.end(); ++i) + { + stream << " " << QuotePath(*i); + } +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index c96ad5a..481a07d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -63,6 +63,7 @@ private: typedef std::map id_map_t; typedef std::map ambiguity_map_t; typedef std::map shortcut_map_t; + typedef std::set extension_set_t; bool InitializeWiXConfiguration(); @@ -129,10 +130,19 @@ private: static bool IsLegalIdCharacter(char c); + void CollectExtensions( + const std::string& variableName, extension_set_t& extensions); + + void AddCustomFlags( + const std::string& variableName, std::ostream& stream); + std::vector wixSources; id_map_t pathToIdMap; ambiguity_map_t idAmbiguityCounter; shortcut_map_t shortcutMap; + + extension_set_t candleExtensions; + extension_set_t lightExtensions; }; #endif -- cgit v0.12