From 378eb5b712bb8f131e62aa343e3ec27d446dc098 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Sat, 1 Mar 2014 23:13:35 +0100 Subject: [PATCH] CPackWIX: Allow Windows Installer property customization --- Modules/CPackWIX.cmake | 17 ++++++++++- Modules/WIX.template.in | 2 ++ Source/CPack/WiX/cmCPackWIXGenerator.cxx | 37 ++++++++++++++++++++++++ Source/CPack/WiX/cmCPackWIXGenerator.h | 2 ++ Source/CPack/cmCPackGenerator.cxx | 6 ++++ Source/CPack/cmCPackGenerator.h | 1 + Tests/CPackWiXGenerator/CMakeLists.txt | 3 ++ 7 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 39183c6e1..0a47e196f 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -216,9 +216,24 @@ # allow other CMake projects to find your package with # the :command:`find_package` command. # +# .. variable:: CPACK_WIX_PROPERTY_ +# +# This variable can be used to provide a value for +# the Windows Installer property ```` +# +# The follwing list contains some example properties that can be used to +# customize information under +# "Programs and Features" (also known as "Add or Remove Programs") +# +# * ARPCOMMENTS - Comments +# * ARPHELPLINK - Help and support information URL +# * ARPURLINFOABOUT - General information URL +# * URLUPDATEINFO - Update information URL +# * ARPHELPTELEPHONE - Help and support telephone number +# * ARPSIZE - Size (in kilobytes) of the application #============================================================================= -# Copyright 2013 Kitware, Inc. +# Copyright 2014 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in index 59a75c75b..bbb7c8831 100644 --- a/Modules/WIX.template.in +++ b/Modules/WIX.template.in @@ -40,5 +40,7 @@ + + diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 8e671ccaf..1ba43b3dd 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -215,6 +215,13 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); } + const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT"); + if(packageContact != 0 && + GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) + { + SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact); + } + CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions); CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions); @@ -239,6 +246,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() } CreateWiXVariablesIncludeFile(); + CreateWiXPropertiesIncludeFile(); if(!CreateWiXSourceFiles()) { @@ -315,6 +323,35 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); } +void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() +{ + std::string includeFilename = + this->CPackTopLevel + "/properties.wxi"; + + cmWIXSourceWriter includeFile( + this->Logger, includeFilename, true); + + std::string prefix = "CPACK_WIX_PROPERTY_"; + std::vector options = GetOptions(); + + for(size_t i = 0; i < options.size(); ++i) + { + std::string const& name = options[i]; + + if(name.length() > prefix.length() && + name.substr(0, prefix.length()) == prefix) + { + std::string id = name.substr(prefix.length()); + std::string value = GetOption(name.c_str()); + + includeFile.BeginElement("Property"); + includeFile.AddAttribute("Id", id); + includeFile.AddAttribute("Value", value); + includeFile.EndElement("Property"); + } + } +} + void cmCPackWIXGenerator::CopyDefinition( cmWIXSourceWriter &source, std::string const& name) { diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index ee66c05d0..4c9f8c764 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -73,6 +73,8 @@ private: void CreateWiXVariablesIncludeFile(); + void CreateWiXPropertiesIncludeFile(); + void CopyDefinition( cmWIXSourceWriter &source, std::string const& name); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 96491aac0..e1dd4e983 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1201,6 +1201,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const return ret; } +//---------------------------------------------------------------------- +std::vector cmCPackGenerator::GetOptions() const +{ + return this->MakefileMap->GetDefinitions(); +} + //---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index bb33aa0f1..b1a7840a2 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -102,6 +102,7 @@ public: void SetOption(const char* op, const char* value); void SetOptionIfNotSet(const char* op, const char* value); const char* GetOption(const char* op) const; + std::vector GetOptions() const; bool IsSet(const char* name) const; bool IsOn(const char* name) const; diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index d673d145d..9957f6b50 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -58,6 +58,9 @@ set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") +set(CPACK_WIX_PROPERTY_ARPCOMMENTS "My Custom ARPCOMMENTS") +set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.cmake.org") + include(CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything")