diff options
author | Brad King <brad.king@kitware.com> | 2014-01-08 14:58:45 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-01-08 14:58:45 (GMT) |
commit | 1857660984e4981ab00070d75e734b7f49d6d9fa (patch) | |
tree | 692e170917957578a004a231302a5d465bfd754b | |
parent | 9551b85a907c10867c466b3cd4d26904acea48f0 (diff) | |
parent | 92c4d4039e6f3c981e8b42d98240e53b8c33bdaf (diff) | |
download | CMake-1857660984e4981ab00070d75e734b7f49d6d9fa.zip CMake-1857660984e4981ab00070d75e734b7f49d6d9fa.tar.gz CMake-1857660984e4981ab00070d75e734b7f49d6d9fa.tar.bz2 |
Merge topic 'wix-cmake-package-registry'
92c4d40 CPackWiX: added new CPACK_WIX_CMAKE_PACKAGE_REGISTRY variable
-rw-r--r-- | Modules/CPackWIX.cmake | 11 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 43 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.h | 3 |
3 files changed, 56 insertions, 1 deletions
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 30f57c7..39183c6 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -205,6 +205,17 @@ # # ``<TOOL>`` can be either LIGHT or CANDLE. # +# .. variable:: CPACK_WIX_CMAKE_PACKAGE_REGISTRY +# +# If this variable is set the generated installer will create +# an entry in the windows registry key +# ``HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<package>`` +# The value for ``<package>`` is provided by this variable. +# +# Assuming you also install a CMake configuration file this will +# allow other CMake projects to find your package with +# the :command:`find_package` command. +# #============================================================================= # Copyright 2013 Kitware, Inc. diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index a55a6a6..998b5f1 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -437,7 +437,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.AddAttribute("Level", "1"); - CreateFeatureHierarchy(featureDefinitions); + if(!CreateCMakePackageRegistryEntry(featureDefinitions)) + { + return false; + } + + if(!CreateFeatureHierarchy(featureDefinitions)) + { + return false; + } featureDefinitions.EndElement("Feature"); @@ -564,6 +572,39 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return true; } +bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry( + cmWIXSourceWriter& featureDefinitions) +{ + const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); + if(!package) + { + return true; + } + + featureDefinitions.BeginElement("Component"); + featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY"); + featureDefinitions.AddAttribute("Directory", "TARGETDIR"); + featureDefinitions.AddAttribute("Guid", "*"); + + std::string registryKey = + std::string("Software\\Kitware\\CMake\\Packages\\") + package; + + std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID"); + + featureDefinitions.BeginElement("RegistryValue"); + featureDefinitions.AddAttribute("Root", "HKLM"); + featureDefinitions.AddAttribute("Key", registryKey); + featureDefinitions.AddAttribute("Name", upgradeGuid); + featureDefinitions.AddAttribute("Type", "string"); + featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]"); + featureDefinitions.AddAttribute("KeyPath", "yes"); + featureDefinitions.EndElement("RegistryValue"); + + featureDefinitions.EndElement("Component"); + + return true; +} + bool cmCPackWIXGenerator::CreateFeatureHierarchy( cmWIXSourceWriter& featureDefinitions) { diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 0a85ae2..1f4facf 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -81,6 +81,9 @@ private: bool CreateWiXSourceFiles(); + bool CreateCMakePackageRegistryEntry( + cmWIXSourceWriter& featureDefinitions); + bool CreateFeatureHierarchy( cmWIXSourceWriter& featureDefinitions); |