diff options
author | Timo Rothenpieler <btbn@btbn.de> | 2014-02-04 17:40:45 (GMT) |
---|---|---|
committer | Nils Gladitz <nilsgladitz@gmail.com> | 2014-02-08 18:19:33 (GMT) |
commit | b78d74de64c989444210b203fb8f1183b2fd0929 (patch) | |
tree | 906011a033416fd26cc077feb8a1ef3ae0875cee /Source/CPack/WiX/cmCPackWIXGenerator.cxx | |
parent | d58280949745660508aa203335dca9b1368817fe (diff) | |
download | CMake-b78d74de64c989444210b203fb8f1183b2fd0929.zip CMake-b78d74de64c989444210b203fb8f1183b2fd0929.tar.gz CMake-b78d74de64c989444210b203fb8f1183b2fd0929.tar.bz2 |
CPackWiX: Add support for CPACK_CREATE_DESKTOP_LINKS
Diffstat (limited to 'Source/CPack/WiX/cmCPackWIXGenerator.cxx')
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 998b5f1..43119d6 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -31,6 +31,12 @@ #include <sys/types.h> #include <sys/stat.h> +cmCPackWIXGenerator::cmCPackWIXGenerator(): + HasDesktopShortcuts(false) +{ + +} + int cmCPackWIXGenerator::InitializeInternal() { componentPackageMethod = ONE_PACKAGE; @@ -519,6 +525,11 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() CreateStartMenuFolder(directoryDefinitions); } + if(this->HasDesktopShortcuts) + { + CreateDesktopFolder(directoryDefinitions); + } + directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Fragment"); @@ -733,10 +744,20 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( } } + std::vector<std::string> cpackPackageDesktopLinksList; + const char *cpackPackageDesktopLinks = + GetOption("CPACK_CREATE_DESKTOP_LINKS"); + if(cpackPackageDesktopLinks) + { + cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks, + cpackPackageDesktopLinksList); + } + AddDirectoryAndFileDefinitons( rootPath, "INSTALL_ROOT", directoryDefinitions, fileDefinitions, featureDefinitions, - cpackPackageExecutablesList, shortcutMap); + cpackPackageExecutablesList, cpackPackageDesktopLinksList, + shortcutMap); featureDefinitions.EndElement("FeatureRef"); @@ -750,6 +771,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions) { + bool thisHasDesktopShortcuts = false; + featureDefinitions.BeginElement("FeatureRef"); featureDefinitions.AddAttribute("Id", featureId); @@ -797,6 +820,11 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.AddAttribute("WorkingDirectory", shortcut.workingDirectoryId); fileDefinitions.EndElement("Shortcut"); + + if (shortcut.desktop) + { + thisHasDesktopShortcuts = true; + } } if(cpackComponentName.empty()) @@ -805,7 +833,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( } fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER" + idSuffix); + fileDefinitions.AddAttribute("Id", + "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix); fileDefinitions.AddAttribute("On", "uninstall"); fileDefinitions.EndElement("RemoveFolder"); @@ -836,6 +865,56 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( featureDefinitions.AddAttribute("Id", componentId); featureDefinitions.EndElement("ComponentRef"); + if (thisHasDesktopShortcuts) + { + this->HasDesktopShortcuts = true; + componentId = "CM_DESKTOP_SHORTCUT" + idSuffix; + + fileDefinitions.BeginElement("DirectoryRef"); + fileDefinitions.AddAttribute("Id", "DesktopFolder"); + fileDefinitions.BeginElement("Component"); + fileDefinitions.AddAttribute("Id", componentId); + fileDefinitions.AddAttribute("Guid", "*"); + + for (shortcut_map_t::const_iterator + i = shortcutMap.begin(); i != shortcutMap.end(); ++i) + { + std::string const& id = i->first; + cmWIXShortcut const& shortcut = i->second; + + if (!shortcut.desktop) + continue; + + std::string shortcutId = std::string("CM_DS") + id; + std::string fileId = std::string("CM_F") + id; + + fileDefinitions.BeginElement("Shortcut"); + fileDefinitions.AddAttribute("Id", shortcutId); + fileDefinitions.AddAttribute("Name", shortcut.textLabel); + std::string target = "[#" + fileId + "]"; + fileDefinitions.AddAttribute("Target", target); + fileDefinitions.AddAttribute("WorkingDirectory", + shortcut.workingDirectoryId); + fileDefinitions.EndElement("Shortcut"); + } + + fileDefinitions.BeginElement("RegistryValue"); + fileDefinitions.AddAttribute("Root", "HKCU"); + fileDefinitions.AddAttribute("Key", registryKey); + fileDefinitions.AddAttribute("Name", valueName + "_desktop"); + fileDefinitions.AddAttribute("Type", "integer"); + fileDefinitions.AddAttribute("Value", "1"); + fileDefinitions.AddAttribute("KeyPath", "yes"); + fileDefinitions.EndElement("RegistryValue"); + + fileDefinitions.EndElement("Component"); + fileDefinitions.EndElement("DirectoryRef"); + + featureDefinitions.BeginElement("ComponentRef"); + featureDefinitions.AddAttribute("Id", componentId); + featureDefinitions.EndElement("ComponentRef"); + } + featureDefinitions.EndElement("FeatureRef"); return true; @@ -908,6 +987,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, const std::vector<std::string>& packageExecutables, + const std::vector<std::string>& desktopExecutables, shortcut_map_t& shortcutMap) { cmsys::Directory dir; @@ -943,6 +1023,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions, featureDefinitions, packageExecutables, + desktopExecutables, shortcutMap); ApplyPatchFragment(subDirectoryId, directoryDefinitions); @@ -995,6 +1076,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXShortcut &shortcut = shortcutMap[id]; shortcut.textLabel= textLabel; shortcut.workingDirectoryId = directoryId; + + if(desktopExecutables.size() && + std::find(desktopExecutables.begin(), + desktopExecutables.end(), + executableName) + != desktopExecutables.end()) + { + shortcut.desktop = true; + } } } } @@ -1232,6 +1322,15 @@ void cmCPackWIXGenerator::CreateStartMenuFolder( directoryDefinitions.EndElement("Directory"); } +void cmCPackWIXGenerator::CreateDesktopFolder( + cmWIXSourceWriter& directoryDefinitions) +{ + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "DesktopFolder"); + directoryDefinitions.AddAttribute("Name", "Desktop"); + directoryDefinitions.EndElement("Directory"); +} + void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) { cmWIXPatchParser parser(Fragments, Logger); |