From 6e51ea9870658ca39e9b3050caada121519da673 Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Wed, 8 May 2013 16:39:32 +0200 Subject: CPackWIX: Handle multiple shortcuts in the start menu --- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index f443905..cfb655b 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -380,7 +380,14 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() directoryDefinitions.EndElement(); directoryDefinitions.EndElement(); - if (dirIdExecutables.size() > 0 && dirIdExecutables.size() % 3 == 0) { + if (dirIdExecutables.size() > 0 && dirIdExecutables.size() % 3 == 0) + { + fileDefinitions.BeginElement("DirectoryRef"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.BeginElement("Component"); + fileDefinitions.AddAttribute("Id", "SHORTCUT"); + fileDefinitions.AddAttribute("Guid", "*"); + std::vector::iterator it; for ( it = dirIdExecutables.begin() ; it != dirIdExecutables.end(); @@ -390,13 +397,12 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string iconName = *it++; std::string directoryId = *it; - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", "SHORTCUT"); - fileDefinitions.AddAttribute("Guid", "*"); fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", "SHORTCUT_"); + std::string shortcutName = fileName; // the iconName is mor likely to contain blanks early on + std::string::size_type const dotPos = shortcutName.find('.'); + if(std::string::npos == dotPos) + { shortcutName = shortcutName.substr(0, dotPos); } + fileDefinitions.AddAttribute("Id", "SHORTCUT_" + shortcutName); fileDefinitions.AddAttribute("Name", iconName); std::string target = "[" + directoryId + "]" + fileName; fileDefinitions.AddAttribute("Target", target); -- cgit v0.12