diff options
author | Nils Gladitz <nilsgladitz@gmail.com> | 2015-02-21 16:30:31 (GMT) |
---|---|---|
committer | Nils Gladitz <nilsgladitz@gmail.com> | 2015-02-21 16:30:31 (GMT) |
commit | 279605f560312aab4dfeef4cce1c8c67d4083b4e (patch) | |
tree | 6f91cd08d36c85c5fafcdef3e70ba2207707c2c3 /Source/CPack/WiX | |
parent | 53d7dafface62d40ea795456394f7ab1d5ee6712 (diff) | |
download | CMake-279605f560312aab4dfeef4cce1c8c67d4083b4e.zip CMake-279605f560312aab4dfeef4cce1c8c67d4083b4e.tar.gz CMake-279605f560312aab4dfeef4cce1c8c67d4083b4e.tar.bz2 |
CPackWIX: Add installed file properties for the creation of shortcuts.
Diffstat (limited to 'Source/CPack/WiX')
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.h | 2 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 13 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFilesSourceWriter.h | 3 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXShortcut.cxx | 40 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXShortcut.h | 12 |
6 files changed, 67 insertions, 12 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index f18eaeb..c6daeda 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -856,8 +856,8 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXFilesSourceWriter& fileDefinitions, cmWIXFeaturesSourceWriter& featureDefinitions, - const std::vector<std::string>& packageExecutables, - const std::vector<std::string>& desktopExecutables, + std::vector<std::string> const& packageExecutables, + std::vector<std::string> const& desktopExecutables, cmWIXShortcuts& shortcuts) { cmsys::Directory dir; @@ -943,6 +943,11 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmInstalledFile const* installedFile = this->GetInstalledFile(relativePath); + if(installedFile) + { + shortcuts.CreateFromProperties(id, directoryId, *installedFile); + } + std::string componentId = fileDefinitions.EmitComponentFile( directoryId, id, fullPath, *(this->Patch), installedFile); diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index d75c69d..d501609 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -136,7 +136,7 @@ private: cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXFilesSourceWriter& fileDefinitions, cmWIXFeaturesSourceWriter& featureDefinitions, - std::vector<std::string> const& pkgExecutables, + std::vector<std::string> const& packageExecutables, std::vector<std::string> const& desktopExecutables, cmWIXShortcuts& shortcuts); diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index ca37699..d4698a7 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -28,16 +28,21 @@ cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, void cmWIXFilesSourceWriter::EmitShortcut( std::string const& id, cmWIXShortcut const& shortcut, - std::string const& shortcutPrefix) + std::string const& shortcutPrefix, + size_t shortcutIndex) { - std::string shortcutId = shortcutPrefix; + std::stringstream shortcutId; + shortcutId << shortcutPrefix << id; - shortcutId += id; + if(shortcutIndex > 0) + { + shortcutId << "_" << shortcutIndex; + } std::string fileId = std::string("CM_F") + id; BeginElement("Shortcut"); - AddAttribute("Id", shortcutId); + AddAttribute("Id", shortcutId.str()); AddAttribute("Name", shortcut.label); std::string target = "[#" + fileId + "]"; AddAttribute("Target", target); diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h index 67808fb..c48bc15 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -31,7 +31,8 @@ public: void EmitShortcut( std::string const& id, cmWIXShortcut const& shortcut, - std::string const& shortcutPrefix); + std::string const& shortcutPrefix, + size_t shortcutIndex); void EmitRemoveFolder(std::string const& id); diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx index 1c755ec..aef2b08 100644 --- a/Source/CPack/WiX/cmWIXShortcut.cxx +++ b/Source/CPack/WiX/cmWIXShortcut.cxx @@ -62,11 +62,12 @@ bool cmWIXShortcuts::EmitShortcuts( std::string const& id = j->first; shortcut_list_t const& shortcutList = j->second; - for(shortcut_list_t::const_iterator k = shortcutList.begin(); - k != shortcutList.end(); ++k) + for(size_t shortcutListIndex = 0; + shortcutListIndex < shortcutList.size(); ++shortcutListIndex) { - cmWIXShortcut const& shortcut = *k; - fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix); + cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex]; + fileDefinitions.EmitShortcut(id, shortcut, + shortcutPrefix, shortcutListIndex); } } @@ -84,3 +85,34 @@ void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types) types.insert(i->first); } } + +void cmWIXShortcuts::CreateFromProperties( + std::string const& id, + std::string const& directoryId, + cmInstalledFile const& installedFile) +{ + CreateFromProperty("CPACK_START_MENU_SHORTCUTS", + START_MENU, id, directoryId, installedFile); + + CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", + DESKTOP, id, directoryId, installedFile); +} + +void cmWIXShortcuts::CreateFromProperty( + std::string const& propertyName, + Type type, + std::string const& id, + std::string const& directoryId, + cmInstalledFile const& installedFile) +{ + std::vector<std::string> list; + installedFile.GetPropertyAsList(propertyName, list); + + for(size_t i = 0; i < list.size(); ++i) + { + cmWIXShortcut shortcut; + shortcut.label = list[i]; + shortcut.workingDirectoryId = directoryId; + insert(type, id, shortcut); + } +} diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h index a18cbb3..5e18bdd 100644 --- a/Source/CPack/WiX/cmWIXShortcut.h +++ b/Source/CPack/WiX/cmWIXShortcut.h @@ -18,6 +18,8 @@ #include <set> #include <vector> +#include <cmInstalledFile.h> + class cmWIXFilesSourceWriter; struct cmWIXShortcut @@ -50,9 +52,19 @@ public: void AddShortcutTypes(std::set<Type>& types); + void CreateFromProperties(std::string const& id, + std::string const& directoryId, cmInstalledFile const& installedFile); + private: typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t; + void CreateFromProperty( + std::string const& propertyName, + Type type, + std::string const& id, + std::string const& directoryId, + cmInstalledFile const& installedFile); + shortcut_type_map_t Shortcuts; shortcut_id_map_t EmptyIdMap; }; |