CPackWIX: Add installed file properties for the creation of shortcuts.
This commit is contained in:
parent
53d7daffac
commit
279605f560
|
@ -320,8 +320,10 @@ Properties on Installed Files
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
|
/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst
|
||||||
/prop_inst/CPACK_NEVER_OVERWRITE.rst
|
/prop_inst/CPACK_NEVER_OVERWRITE.rst
|
||||||
/prop_inst/CPACK_PERMANENT.rst
|
/prop_inst/CPACK_PERMANENT.rst
|
||||||
|
/prop_inst/CPACK_START_MENU_SHORTCUTS.rst
|
||||||
/prop_inst/CPACK_WIX_ACL.rst
|
/prop_inst/CPACK_WIX_ACL.rst
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
CPACK_DESKTOP_SHORTCUTS
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Species a list of shortcut names that should be created on the Desktop
|
||||||
|
for this file.
|
||||||
|
|
||||||
|
The property is currently only supported by the WIX generator.
|
|
@ -0,0 +1,7 @@
|
||||||
|
CPACK_START_MENU_SHORTCUTS
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Species a list of shortcut names that should be created in the Start Menu
|
||||||
|
for this file.
|
||||||
|
|
||||||
|
The property is currently only supported by the WIX generator.
|
|
@ -856,8 +856,8 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
|
||||||
cmWIXDirectoriesSourceWriter& directoryDefinitions,
|
cmWIXDirectoriesSourceWriter& directoryDefinitions,
|
||||||
cmWIXFilesSourceWriter& fileDefinitions,
|
cmWIXFilesSourceWriter& fileDefinitions,
|
||||||
cmWIXFeaturesSourceWriter& featureDefinitions,
|
cmWIXFeaturesSourceWriter& featureDefinitions,
|
||||||
const std::vector<std::string>& packageExecutables,
|
std::vector<std::string> const& packageExecutables,
|
||||||
const std::vector<std::string>& desktopExecutables,
|
std::vector<std::string> const& desktopExecutables,
|
||||||
cmWIXShortcuts& shortcuts)
|
cmWIXShortcuts& shortcuts)
|
||||||
{
|
{
|
||||||
cmsys::Directory dir;
|
cmsys::Directory dir;
|
||||||
|
@ -943,6 +943,11 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
|
||||||
cmInstalledFile const* installedFile =
|
cmInstalledFile const* installedFile =
|
||||||
this->GetInstalledFile(relativePath);
|
this->GetInstalledFile(relativePath);
|
||||||
|
|
||||||
|
if(installedFile)
|
||||||
|
{
|
||||||
|
shortcuts.CreateFromProperties(id, directoryId, *installedFile);
|
||||||
|
}
|
||||||
|
|
||||||
std::string componentId = fileDefinitions.EmitComponentFile(
|
std::string componentId = fileDefinitions.EmitComponentFile(
|
||||||
directoryId, id, fullPath, *(this->Patch), installedFile);
|
directoryId, id, fullPath, *(this->Patch), installedFile);
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ private:
|
||||||
cmWIXDirectoriesSourceWriter& directoryDefinitions,
|
cmWIXDirectoriesSourceWriter& directoryDefinitions,
|
||||||
cmWIXFilesSourceWriter& fileDefinitions,
|
cmWIXFilesSourceWriter& fileDefinitions,
|
||||||
cmWIXFeaturesSourceWriter& featureDefinitions,
|
cmWIXFeaturesSourceWriter& featureDefinitions,
|
||||||
std::vector<std::string> const& pkgExecutables,
|
std::vector<std::string> const& packageExecutables,
|
||||||
std::vector<std::string> const& desktopExecutables,
|
std::vector<std::string> const& desktopExecutables,
|
||||||
cmWIXShortcuts& shortcuts);
|
cmWIXShortcuts& shortcuts);
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,21 @@ cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
|
||||||
void cmWIXFilesSourceWriter::EmitShortcut(
|
void cmWIXFilesSourceWriter::EmitShortcut(
|
||||||
std::string const& id,
|
std::string const& id,
|
||||||
cmWIXShortcut const& shortcut,
|
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;
|
std::string fileId = std::string("CM_F") + id;
|
||||||
|
|
||||||
BeginElement("Shortcut");
|
BeginElement("Shortcut");
|
||||||
AddAttribute("Id", shortcutId);
|
AddAttribute("Id", shortcutId.str());
|
||||||
AddAttribute("Name", shortcut.label);
|
AddAttribute("Name", shortcut.label);
|
||||||
std::string target = "[#" + fileId + "]";
|
std::string target = "[#" + fileId + "]";
|
||||||
AddAttribute("Target", target);
|
AddAttribute("Target", target);
|
||||||
|
|
|
@ -31,7 +31,8 @@ public:
|
||||||
void EmitShortcut(
|
void EmitShortcut(
|
||||||
std::string const& id,
|
std::string const& id,
|
||||||
cmWIXShortcut const& shortcut,
|
cmWIXShortcut const& shortcut,
|
||||||
std::string const& shortcutPrefix);
|
std::string const& shortcutPrefix,
|
||||||
|
size_t shortcutIndex);
|
||||||
|
|
||||||
void EmitRemoveFolder(std::string const& id);
|
void EmitRemoveFolder(std::string const& id);
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,12 @@ bool cmWIXShortcuts::EmitShortcuts(
|
||||||
std::string const& id = j->first;
|
std::string const& id = j->first;
|
||||||
shortcut_list_t const& shortcutList = j->second;
|
shortcut_list_t const& shortcutList = j->second;
|
||||||
|
|
||||||
for(shortcut_list_t::const_iterator k = shortcutList.begin();
|
for(size_t shortcutListIndex = 0;
|
||||||
k != shortcutList.end(); ++k)
|
shortcutListIndex < shortcutList.size(); ++shortcutListIndex)
|
||||||
{
|
{
|
||||||
cmWIXShortcut const& shortcut = *k;
|
cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex];
|
||||||
fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix);
|
fileDefinitions.EmitShortcut(id, shortcut,
|
||||||
|
shortcutPrefix, shortcutListIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,3 +85,34 @@ void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
|
||||||
types.insert(i->first);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <cmInstalledFile.h>
|
||||||
|
|
||||||
class cmWIXFilesSourceWriter;
|
class cmWIXFilesSourceWriter;
|
||||||
|
|
||||||
struct cmWIXShortcut
|
struct cmWIXShortcut
|
||||||
|
@ -50,9 +52,19 @@ public:
|
||||||
|
|
||||||
void AddShortcutTypes(std::set<Type>& types);
|
void AddShortcutTypes(std::set<Type>& types);
|
||||||
|
|
||||||
|
void CreateFromProperties(std::string const& id,
|
||||||
|
std::string const& directoryId, cmInstalledFile const& installedFile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t;
|
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_type_map_t Shortcuts;
|
||||||
shortcut_id_map_t EmptyIdMap;
|
shortcut_id_map_t EmptyIdMap;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue