Merge topic 'wix-custom-arguments'

096591b CPackWiX: Add variables for custom tool extensions and flags
This commit is contained in:
Brad King 2013-11-13 09:56:30 -05:00 committed by CMake Topic Stage
commit 3822f5bcac
3 changed files with 96 additions and 7 deletions

View File

@ -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_<TOOL>_EXTENSIONS
#
# This is the tool specific version of CPACK_WIX_EXTENSIONS.
# ``<TOOL>`` can be either LIGHT or CANDLE.
#
# .. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS
#
# This list variable allows you to pass additional
# flags to the WiX tool ``<TOOL>``.
#
# Use it at your own risk.
# Future versions of CPack may generate flags which may be in conflict
# with your own flags.
#
# ``<TOOL>`` 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.

View File

@ -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());
@ -180,6 +198,13 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
<< 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<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
for(std::vector<std::string>::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<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
for(std::vector<std::string>::const_iterator i = list.begin();
i != list.end(); ++i)
{
stream << " " << QuotePath(*i);
}
}

View File

@ -63,6 +63,7 @@ private:
typedef std::map<std::string, std::string> id_map_t;
typedef std::map<std::string, size_t> ambiguity_map_t;
typedef std::map<std::string, cmWIXShortcut> shortcut_map_t;
typedef std::set<std::string> 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<std::string> wixSources;
id_map_t pathToIdMap;
ambiguity_map_t idAmbiguityCounter;
shortcut_map_t shortcutMap;
extension_set_t candleExtensions;
extension_set_t lightExtensions;
};
#endif