CPackIFW: Revise this generator

CPack IFW generator updates:
- Group now can have script;
- Root package (for monolithic or one package installers) can be
  configured from group.

CMake updates:
- Native installation (no Unspecified component).
This commit is contained in:
Konstantin Podsvirov 2014-08-12 22:44:02 +04:00 committed by Brad King
parent 1f8cfc3b5f
commit e6496b6023
9 changed files with 148 additions and 58 deletions

View File

@ -65,16 +65,9 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
endif() endif()
endif() endif()
# default component for IFW
if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
set(_CPACK_IFW_COMPONENT_NAME ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
else()
set(_CPACK_IFW_COMPONENT_NAME Unspecified)
endif()
string(TOUPPER ${_CPACK_IFW_COMPONENT_NAME} _CPACK_IFW_COMPONENT_UNAME)
if(${CMAKE_SYSTEM_NAME} MATCHES Windows) if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
set(_CPACK_IFW_PACKAGE_ICON "set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")") set(_CPACK_IFW_PACKAGE_ICON
"set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")")
if(BUILD_QtDialog) if(BUILD_QtDialog)
set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n") set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n")
endif() endif()
@ -87,7 +80,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html" install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html"
DESTINATION "." DESTINATION "."
) )
set(_CPACK_IFW_COMPONENT_SCRIPT "set(CPACK_IFW_COMPONENT_${_CPACK_IFW_COMPONENT_UNAME}_SCRIPT \"${CMake_BINARY_DIR}/installscript.qs\")") set(_CPACK_IFW_PACKAGE_SCRIPT "set(CPACK_IFW_COMPONENT_GROUP_CMAKE_SCRIPT \"${CMake_BINARY_DIR}/installscript.qs\")")
endif() endif()
if(${CMAKE_SYSTEM_NAME} MATCHES Linux) if(${CMAKE_SYSTEM_NAME} MATCHES Linux)

View File

@ -32,22 +32,25 @@ endif()
include("@QT_DIALOG_CPACK_OPTIONS_FILE@" OPTIONAL) include("@QT_DIALOG_CPACK_OPTIONS_FILE@" OPTIONAL)
if(CPACK_GENERATOR MATCHES "IFW") if(CPACK_GENERATOR MATCHES "IFW")
# Version with QtIFW limitations
set(CPACK_PACKAGE_VERSION "@_CPACK_IFW_PACKAGE_VERSION@")
# Installer configuration # Installer configuration
set(CPACK_IFW_PACKAGE_TITLE "CMake Build Tool") set(CPACK_IFW_PACKAGE_TITLE "CMake Build Tool")
set(CPACK_IFW_PRODUCT_URL "http://www.cmake.org") set(CPACK_IFW_PRODUCT_URL "http://www.cmake.org")
@_CPACK_IFW_PACKAGE_ICON@ @_CPACK_IFW_PACKAGE_ICON@
set(CPACK_IFW_PACKAGE_WINDOW_ICON "@CMake_SOURCE_DIR@/Source/QtDialog/CMakeSetup128.png") set(CPACK_IFW_PACKAGE_WINDOW_ICON
# Enable install default component "@CMake_SOURCE_DIR@/Source/QtDialog/CMakeSetup128.png")
set(CPACK_COMPONENTS_ALL "@_CPACK_IFW_COMPONENT_NAME@") # Package configuration group
# Component configuration set(CPACK_IFW_PACKAGE_GROUP CMake)
set(CPACK_COMPONENT_@_CPACK_IFW_COMPONENT_UNAME@_DISPLAY_NAME "@CPACK_PACKAGE_NAME@") # Group configuration
set(CPACK_COMPONENT_@_CPACK_IFW_COMPONENT_UNAME@_DESCRIPTION "@CPACK_PACKAGE_DESCRIPTION_SUMMARY@") set(CPACK_COMPONENT_GROUP_CMAKE_DISPLAY_NAME
# IFW component onfiguration "@CPACK_PACKAGE_NAME@")
set(CPACK_IFW_COMPONENT_@_CPACK_IFW_COMPONENT_UNAME@_NAME "@CPACK_PACKAGE_NAME@") set(CPACK_COMPONENT_GROUP_CMAKE_DESCRIPTION
set(CPACK_IFW_COMPONENT_@_CPACK_IFW_COMPONENT_UNAME@_LICENSES "@CPACK_PACKAGE_NAME@ Copyright" "@CPACK_RESOURCE_FILE_LICENSE@") "@CPACK_PACKAGE_DESCRIPTION_SUMMARY@")
@_CPACK_IFW_COMPONENT_SCRIPT@ # IFW group configuration
set(CPACK_IFW_COMPONENT_GROUP_CMAKE_VERSION
"@_CPACK_IFW_PACKAGE_VERSION@")
set(CPACK_IFW_COMPONENT_GROUP_CMAKE_LICENSES
"@CPACK_PACKAGE_NAME@ Copyright" "@CPACK_RESOURCE_FILE_LICENSE@")
@_CPACK_IFW_PACKAGE_SCRIPT@
endif() endif()
if(CPACK_GENERATOR MATCHES "CygwinSource") if(CPACK_GENERATOR MATCHES "CygwinSource")

View File

@ -74,6 +74,15 @@
# #
# You can use predefined variables. # You can use predefined variables.
# #
# .. variable:: CPACK_IFW_PACKAGE_GROUP
#
# The group, which will be used to configure the root package
#
# .. variable:: CPACK_IFW_PACKAGE_NAME
#
# The root package name, which will be used if configuration group is not
# specified
#
# Components # Components
# """""""""" # """"""""""
# #
@ -122,11 +131,10 @@
# #
# :: # ::
# #
# cpack_ifw_configure_component(<compname> # cpack_ifw_configure_component(<compname> [COMMON]
# [COMMON] # [NAME <name>]
# [VERSION <version>] # [VERSION <version>]
# [SCRIPT <script>] # [SCRIPT <script>]
# [NAME <name>]
# [PRIORITY <priority>] # [PRIORITY <priority>]
# [DEPENDS <com_id> ...] # [DEPENDS <com_id> ...]
# [LICENSES <display_name> <file_path> ...]) # [LICENSES <display_name> <file_path> ...])
@ -163,6 +171,7 @@
# cpack_ifw_configure_component_group(<grpname> # cpack_ifw_configure_component_group(<grpname>
# [VERSION <version>] # [VERSION <version>]
# [NAME <name>] # [NAME <name>]
# [SCRIPT <script>]
# [PRIORITY <priority>] # [PRIORITY <priority>]
# [LICENSES <display_name> <file_path> ...]) # [LICENSES <display_name> <file_path> ...])
# #
@ -174,6 +183,9 @@
# ``NAME`` is used to create domain-like identification for this component group. # ``NAME`` is used to create domain-like identification for this component group.
# By default used origin component group name. # By default used origin component group name.
# #
# ``SCRIPT`` is relative or absolute path to operations script
# for this component group.
#
# ``PRIORITY`` is priority of the component group in the tree. # ``PRIORITY`` is priority of the component group in the tree.
# #
# ``LICENSES`` pair of <display_name> and <file_path> of license text for this # ``LICENSES`` pair of <display_name> and <file_path> of license text for this
@ -329,6 +341,20 @@ if(NOT __CMAKE_PARSE_ARGUMENTS_INCLUDED)
include(CMakeParseArguments) include(CMakeParseArguments)
endif() endif()
# Resolve full filename for script file
macro(_cpack_ifw_resolve_script _variable)
set(_ifw_script_macro ${_variable})
set(_ifw_script_file ${${_ifw_script_macro}})
if(DEFINED ${_ifw_script_macro})
get_filename_component(${_ifw_script_macro} ${_ifw_script_file} ABSOLUTE)
set(_ifw_script_file ${${_ifw_script_macro}})
if(NOT EXISTS ${_ifw_script_file})
message(WARNING "CPack IFW: script file \"${_ifw_script_file}\" is not exists")
set(${_ifw_script_macro})
endif()
endif()
endmacro()
# Resolve full path to lisense file # Resolve full path to lisense file
macro(_cpack_ifw_resolve_lisenses _variable) macro(_cpack_ifw_resolve_lisenses _variable)
if(${_variable}) if(${_variable})
@ -357,18 +383,7 @@ macro(cpack_ifw_configure_component compname)
set(_IFW_MULTI_ARGS DEPENDS LICENSES) set(_IFW_MULTI_ARGS DEPENDS LICENSES)
cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
# Resolve full filename for script file _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
set(_IFW_SCRIPT_MACRO CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
set(_IFW_SCRIPT_FILE ${${_IFW_SCRIPT_MACRO}})
if(DEFINED ${_IFW_SCRIPT_MACRO})
get_filename_component(${_IFW_SCRIPT_MACRO} ${_IFW_SCRIPT_FILE} ABSOLUTE)
set(_IFW_SCRIPT_FILE ${${_IFW_SCRIPT_MACRO}})
if(NOT EXISTS ${_IFW_SCRIPT_FILE})
message(WARNING "CPack IFW: script file \"${_IFW_SCRIPT_FILE}\" for component \"${compname}\" is not exists" )
set(${_IFW_SCRIPT_MACRO})
endif()
endif()
_cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES) _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES)
set(_CPACK_IFWCOMP_STR "\n# Configuration for IFW component \"${compname}\"\n") set(_CPACK_IFWCOMP_STR "\n# Configuration for IFW component \"${compname}\"\n")
@ -403,10 +418,11 @@ macro(cpack_ifw_configure_component_group grpname)
string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME) string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME)
set(_IFW_OPT) set(_IFW_OPT)
set(_IFW_ARGS VERSION NAME PRIORITY) set(_IFW_ARGS NAME VERSION SCRIPT PRIORITY)
set(_IFW_MULTI_ARGS LICENSES) set(_IFW_MULTI_ARGS LICENSES)
cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN}) cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
_cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT)
_cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_LICENSES) _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_LICENSES)
set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n") set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n")

View File

@ -33,8 +33,6 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCPackIFWGenerator::cmCPackIFWGenerator() cmCPackIFWGenerator::cmCPackIFWGenerator()
{ {
// Change the default behavior
componentPackageMethod = ONE_PACKAGE_PER_COMPONENT;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -374,9 +372,6 @@ cmCPackComponentGroup*
cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName, cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
const std::string &groupName) const std::string &groupName)
{ {
ComponentGoupsMap::iterator git = ComponentGroups.find(groupName);
if ( git != ComponentGroups.end() ) return &(git->second);
cmCPackComponentGroup* group cmCPackComponentGroup* group
= cmCPackGenerator::GetComponentGroup(projectName, groupName); = cmCPackGenerator::GetComponentGroup(projectName, groupName);
if(!group) return group; if(!group) return group;
@ -388,7 +383,7 @@ cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
cmCPackIFWPackage *package = &Packages[name]; cmCPackIFWPackage *package = &Packages[name];
package->Name = name; package->Name = name;
package->Generator = this; package->Generator = this;
if(package->ConfigureFromComponentGroup(group)) if(package->ConfigureFromGroup(group))
{ {
package->Installer = &Installer; package->Installer = &Installer;
Installer.Packages.insert( Installer.Packages.insert(
@ -436,17 +431,29 @@ bool cmCPackIFWGenerator::IsOnePackage() const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmCPackIFWGenerator::GetRootPackageName() const std::string cmCPackIFWGenerator::GetRootPackageName()
{ {
// Default value
std::string name = "root"; std::string name = "root";
if(const char* optIFW_ROOT_PACKAGE_NAME = if (const char* optIFW_PACKAGE_GROUP =
this->GetOption("CPACK_IFW_ROOT_PACKAGE_NAME")) this->GetOption("CPACK_IFW_PACKAGE_GROUP"))
{ {
name = optIFW_ROOT_PACKAGE_NAME; // Configure from root group
cmCPackIFWPackage package;
package.Generator = this;
package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
name = package.Name;
}
else if (const char* optIFW_PACKAGE_NAME =
this->GetOption("CPACK_IFW_PACKAGE_NAME"))
{
// Configure from root package name
name = optIFW_PACKAGE_NAME;
} }
else if (const char* optPACKAGE_NAME = else if (const char* optPACKAGE_NAME =
this->GetOption("CPACK_PACKAGE_NAME")) this->GetOption("CPACK_PACKAGE_NAME"))
{ {
// Configure from package name
name = optPACKAGE_NAME; name = optPACKAGE_NAME;
} }
return name; return name;

View File

@ -97,7 +97,7 @@ protected: // Methods
bool IsOnePackage() const; bool IsOnePackage() const;
std::string GetRootPackageName() const; std::string GetRootPackageName();
std::string GetGroupPackageName(cmCPackComponentGroup *group) const; std::string GetGroupPackageName(cmCPackComponentGroup *group) const;
std::string GetComponentPackageName(cmCPackComponent *component) const; std::string GetComponentPackageName(cmCPackComponent *component) const;

View File

@ -48,9 +48,15 @@ const char *cmCPackIFWInstaller::GetOption(const std::string &op) const
void cmCPackIFWInstaller::ConfigureFromOptions() void cmCPackIFWInstaller::ConfigureFromOptions()
{ {
// Name; // Name;
if (const char* option = GetOption("CPACK_PACKAGE_NAME")) if (const char* optIFW_PACKAGE_NAME =
this->GetOption("CPACK_IFW_PACKAGE_NAME"))
{ {
Name = option; Name = optIFW_PACKAGE_NAME;
}
else if (const char* optPACKAGE_NAME =
this->GetOption("CPACK_PACKAGE_NAME"))
{
Name = optPACKAGE_NAME;
} }
else else
{ {
@ -274,7 +280,16 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
cmCPackIFWPackage package; cmCPackIFWPackage package;
package.Generator = Generator; package.Generator = Generator;
package.Installer = this; package.Installer = this;
package.ConfigureFromOptions(); // Check package group
if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP"))
{
package.ConfigureFromGroup(option);
package.ForcedInstallation = "true";
}
else
{
package.ConfigureFromOptions();
}
package.GeneratePackageFile(); package.GeneratePackageFile();
return; return;
} }

View File

@ -13,7 +13,7 @@
#ifndef cmCPackIFWInstaller_h #ifndef cmCPackIFWInstaller_h
#define cmCPackIFWInstaller_h #define cmCPackIFWInstaller_h
#include "cmStandardIncludes.h" #include <cmStandardIncludes.h>
class cmCPackIFWPackage; class cmCPackIFWPackage;
class cmCPackIFWGenerator; class cmCPackIFWGenerator;

View File

@ -121,7 +121,14 @@ cmCPackIFWPackage::cmCPackIFWPackage() :
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char *cmCPackIFWPackage::GetOption(const std::string &op) const const char *cmCPackIFWPackage::GetOption(const std::string &op) const
{ {
return Generator ? Generator->GetOption(op) : 0; const char *option = Generator ? Generator->GetOption(op) : 0;
return option && *option ? option : 0;
}
//----------------------------------------------------------------------------
bool cmCPackIFWPackage::IsOn(const std::string &op) const
{
return Generator ? Generator->IsOn(op) : false;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -232,7 +239,6 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
// Script // Script
if (const char* option = GetOption(prefix + "SCRIPT")) if (const char* option = GetOption(prefix + "SCRIPT"))
{ {
// TODO: add check file exist
Script = option; Script = option;
} }
@ -306,7 +312,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int int
cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group) cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
{ {
if(!group) return 0; if(!group) return 0;
@ -335,6 +341,12 @@ cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group)
Version = "1.0.0"; Version = "1.0.0";
} }
// Script
if (const char* option = GetOption(prefix + "SCRIPT"))
{
Script = option;
}
// Licenses // Licenses
if (const char* option = this->GetOption(prefix + "LICENSES")) if (const char* option = this->GetOption(prefix + "LICENSES"))
{ {
@ -358,6 +370,48 @@ cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group)
return 1; return 1;
} }
//----------------------------------------------------------------------------
int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
{
// Group configuration
cmCPackComponentGroup group;
std::string prefix = "CPACK_COMPONENT_GROUP_"
+ cmsys::SystemTools::UpperCase(groupName)
+ "_";
if (const char *option = GetOption(prefix + "DISPLAY_NAME"))
{
group.DisplayName = option;
}
else
{
group.DisplayName = group.Name;
}
if (const char* option = GetOption(prefix + "DESCRIPTION"))
{
group.Description = option;
}
group.IsBold = IsOn(prefix + "BOLD_TITLE");
group.IsExpandedByDefault = IsOn(prefix + "EXPANDED");
// Package configuration
group.Name = groupName;
if(Generator)
{
Name = Generator->GetGroupPackageName(&group);
}
else
{
Name = group.Name;
}
return ConfigureFromGroup(&group);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmCPackIFWPackage::GeneratePackageFile() void cmCPackIFWPackage::GeneratePackageFile()
{ {

View File

@ -13,7 +13,7 @@
#ifndef cmCPackIFWPackage_h #ifndef cmCPackIFWPackage_h
#define cmCPackIFWPackage_h #define cmCPackIFWPackage_h
#include "cmStandardIncludes.h" #include <cmStandardIncludes.h>
class cmCPackComponent; class cmCPackComponent;
class cmCPackComponentGroup; class cmCPackComponentGroup;
@ -105,6 +105,7 @@ public: // Configuration
public: // Internal implementation public: // Internal implementation
const char* GetOption(const std::string& op) const; const char* GetOption(const std::string& op) const;
bool IsOn(const std::string& op) const;
std::string GetComponentName(cmCPackComponent *component); std::string GetComponentName(cmCPackComponent *component);
@ -112,7 +113,8 @@ public: // Internal implementation
int ConfigureFromOptions(); int ConfigureFromOptions();
int ConfigureFromComponent(cmCPackComponent *component); int ConfigureFromComponent(cmCPackComponent *component);
int ConfigureFromComponentGroup(cmCPackComponentGroup *group); int ConfigureFromGroup(cmCPackComponentGroup *group);
int ConfigureFromGroup(const std::string &groupName);
void GeneratePackageFile(); void GeneratePackageFile();