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()
# 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)
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)
set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n")
endif()
@ -87,7 +80,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html"
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()
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)

View File

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

View File

@ -74,6 +74,15 @@
#
# 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
# """"""""""
#
@ -122,11 +131,10 @@
#
# ::
#
# cpack_ifw_configure_component(<compname>
# [COMMON]
# cpack_ifw_configure_component(<compname> [COMMON]
# [NAME <name>]
# [VERSION <version>]
# [SCRIPT <script>]
# [NAME <name>]
# [PRIORITY <priority>]
# [DEPENDS <com_id> ...]
# [LICENSES <display_name> <file_path> ...])
@ -163,6 +171,7 @@
# cpack_ifw_configure_component_group(<grpname>
# [VERSION <version>]
# [NAME <name>]
# [SCRIPT <script>]
# [PRIORITY <priority>]
# [LICENSES <display_name> <file_path> ...])
#
@ -174,6 +183,9 @@
# ``NAME`` is used to create domain-like identification for this component group.
# 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.
#
# ``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)
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
macro(_cpack_ifw_resolve_lisenses _variable)
if(${_variable})
@ -357,18 +383,7 @@ macro(cpack_ifw_configure_component compname)
set(_IFW_MULTI_ARGS DEPENDS LICENSES)
cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
# Resolve full filename for script file
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_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
_cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES)
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)
set(_IFW_OPT)
set(_IFW_ARGS VERSION NAME PRIORITY)
set(_IFW_ARGS NAME VERSION SCRIPT PRIORITY)
set(_IFW_MULTI_ARGS LICENSES)
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)
set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n")

View File

@ -33,8 +33,6 @@
//----------------------------------------------------------------------------
cmCPackIFWGenerator::cmCPackIFWGenerator()
{
// Change the default behavior
componentPackageMethod = ONE_PACKAGE_PER_COMPONENT;
}
//----------------------------------------------------------------------------
@ -374,9 +372,6 @@ cmCPackComponentGroup*
cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
const std::string &groupName)
{
ComponentGoupsMap::iterator git = ComponentGroups.find(groupName);
if ( git != ComponentGroups.end() ) return &(git->second);
cmCPackComponentGroup* group
= cmCPackGenerator::GetComponentGroup(projectName, groupName);
if(!group) return group;
@ -388,7 +383,7 @@ cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
cmCPackIFWPackage *package = &Packages[name];
package->Name = name;
package->Generator = this;
if(package->ConfigureFromComponentGroup(group))
if(package->ConfigureFromGroup(group))
{
package->Installer = &Installer;
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";
if(const char* optIFW_ROOT_PACKAGE_NAME =
this->GetOption("CPACK_IFW_ROOT_PACKAGE_NAME"))
if (const char* optIFW_PACKAGE_GROUP =
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 =
this->GetOption("CPACK_PACKAGE_NAME"))
{
// Configure from package name
name = optPACKAGE_NAME;
}
return name;

View File

@ -97,7 +97,7 @@ protected: // Methods
bool IsOnePackage() const;
std::string GetRootPackageName() const;
std::string GetRootPackageName();
std::string GetGroupPackageName(cmCPackComponentGroup *group) 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()
{
// 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
{
@ -274,7 +280,16 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
cmCPackIFWPackage package;
package.Generator = Generator;
package.Installer = this;
// Check package group
if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP"))
{
package.ConfigureFromGroup(option);
package.ForcedInstallation = "true";
}
else
{
package.ConfigureFromOptions();
}
package.GeneratePackageFile();
return;
}

View File

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

View File

@ -121,7 +121,14 @@ cmCPackIFWPackage::cmCPackIFWPackage() :
//----------------------------------------------------------------------------
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
if (const char* option = GetOption(prefix + "SCRIPT"))
{
// TODO: add check file exist
Script = option;
}
@ -306,7 +312,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
//----------------------------------------------------------------------------
int
cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group)
cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
{
if(!group) return 0;
@ -335,6 +341,12 @@ cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group)
Version = "1.0.0";
}
// Script
if (const char* option = GetOption(prefix + "SCRIPT"))
{
Script = option;
}
// Licenses
if (const char* option = this->GetOption(prefix + "LICENSES"))
{
@ -358,6 +370,48 @@ cmCPackIFWPackage::ConfigureFromComponentGroup(cmCPackComponentGroup *group)
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()
{

View File

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