ENH: cpack changes, remove the escape variable stuff as it is not needed if you provide a config file for cpack

This commit is contained in:
Bill Hoffman 2007-10-30 23:02:43 -04:00
parent 9bd0d0f1ed
commit eb14543939
6 changed files with 80 additions and 168 deletions

View File

@ -37,60 +37,13 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
SET(CPACK_PACKAGE_CONTACT "cmake@cmake.org")
IF(WIN32 AND NOT UNIX)
# set the install/unistall icon used for the installer itself
SET(CPACK_NSIS_MUI_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\CMakeLogo.ico")
SET(CPACK_NSIS_MUI_UNIICON "${CMake_SOURCE_DIR}/Utilities/Release\\CMakeLogo.ico")
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\CMakeInstall.bmp")
# tell cpack the executables you want in the start menu as links
SET(CPACK_PACKAGE_EXECUTABLES "CMakeSetup" "CMake" )
# tell cpack to create a desktop link to CMakeSetup
SET(CPACK_CREATE_DESKTOP_LINK_CMakeSetup ON)
# These variables should have escapes preserved during the
# translation to the CPackConfig.cmake file. By default,
# CPack will require double escapes as it gets parsed by
# cmake twice
SET(CPACK_ESCAPE_VARIABLES
CPACK_PACKAGE_ICON
CPACK_NSIS_MUI_ICON
CPACK_NSIS_MUI_UNIICON
)
# tell cpack to create links to the doc files
SET(CPACK_NSIS_MENU_LINKS
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/CMakeSetup.html" "CMakeSetup Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake.html" "CMake Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-properties.html"
"CMake Properties and Variables Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/ctest.html" "CTest Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-modules.html" "CMake Modules Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-commands.html" "CMake Commands Help"
"doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cpack.html" "CPack Help"
"http://www.cmake.org" "CMake Web Site"
)
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\CMakeSetup.exe")
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} a cross-platform, open-source build system")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cmake.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.kitware.com")
SET(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
IF(UNIX)
SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")
SET(CPACK_SOURCE_STRIP_FILES "")
SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
ENDIF(WIN32 AND NOT UNIX)
ENDIF(UNIX)
# cygwin specific packaging stuff
IF(CYGWIN)
SET(CPACK_PACKAGE_NAME cmake)
# setup the name of the package for cygwin cmake-2.4.3
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
# the source has the same name as the binary
SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
# Create a cygwin version number in case there are changes for cygwin
# that are not reflected upstream in CMake
SET(CPACK_CYGWIN_PATCH_NUMBER 1)
# if we are on cygwin and have cpack, then force the
# doc, data and man dirs to conform to cygwin style directories
SET(CMAKE_DOC_DIR "/share/doc/${CPACK_PACKAGE_FILE_NAME}")
@ -101,17 +54,27 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
MESSAGE(STATUS "Override cache CMAKE_DOC_DIR = ${CMAKE_DOC_DIR}")
MESSAGE(STATUS "Override cache CMAKE_DATA_DIR = ${CMAKE_DATA_DIR}")
MESSAGE(STATUS "Override cache CMAKE_MAN_DIR = ${CMAKE_MAN_DIR}")
# setup the cygwin package name
SET(CPACK_PACKAGE_NAME cmake)
# setup the name of the package for cygwin cmake-2.4.3
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
# the source has the same name as the binary
SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
# Create a cygwin version number in case there are changes for cygwin
# that are not reflected upstream in CMake
SET(CPACK_CYGWIN_PATCH_NUMBER 1)
# These files are required by the cmCPackCygwinSourceGenerator and the files
# put into the release tar files.
SET(CPACK_CYGWIN_BUILD_SCRIPT
"${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.sh")
SET(CPACK_CYGWIN_PATCH_FILE
"${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.patch")
# include the sub directory for cygwin releases
# include the sub directory cmake file for cygwin that
# configures some files and adds some install targets
# this file uses some of the package file name variables
INCLUDE(Utilities/Release/Cygwin/CMakeLists.txt)
# when packaging source make sure the .build directory is not included
SET(CPACK_SOURCE_IGNORE_FILES
"/CVS/" "/\\\\.build/" "/\\\\.svn/" "\\\\.swp$" "\\\\.#" "/#" "~$")
ENDIF(CYGWIN)
# include CPack model once all variables are set
INCLUDE(CPack)

33
CPackConfig.cmake.in Normal file
View File

@ -0,0 +1,33 @@
# all CPACK_ variables from the cmake project
@_CPACK_OTHER_VARIABLES_@
if(CPACK_GENERATOR MATCHES "NSIS")
# set the install/unistall icon used for the installer itself
# There is a bug in NSI that does not handle full unix paths properly.
SET(CPACK_NSIS_MUI_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico")
SET(CPACK_NSIS_MUI_UNIICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico")
# set the package header icon for MUI
SET(CPACK_PACKAGE_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeInstall.bmp")
# tell cpack to create links to the doc files
SET(CPACK_NSIS_MENU_LINKS
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/CMakeSetup.html" "CMakeSetup Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" "CMake Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-properties.html"
"CMake Properties and Variables Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/ctest.html" "CTest Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-modules.html" "CMake Modules Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-commands.html" "CMake Commands Help"
"doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cpack.html" "CPack Help"
"http://www.cmake.org" "CMake Web Site"
)
# tell cpack the executables you want in the start menu as links
SET(CPACK_PACKAGE_EXECUTABLES "CMakeSetup" "CMake" )
# tell cpack to create a desktop link to CMakeSetup
SET(CPACK_CREATE_DESKTOP_LINK_CMakeSetup ON)
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\CMakeSetup.exe")
SET(CPACK_NSIS_DISPLAY_NAME "@CPACK_PACKAGE_INSTALL_DIRECTORY@ a cross-platform, open-source build system")
SET(CPACK_NSIS_HELP_LINK "http:\\\\www.cmake.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\www.kitware.com")
SET(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@)
SET(CPACK_NSIS_MODIFY_PATH ON)
endif(CPACK_GENERATOR MATCHES "NSIS")

View File

@ -0,0 +1,8 @@
# All CPACK_ variables from the cmake project
@_CPACK_OTHER_VARIABLES_@
if(CPACK_GENERATOR MATCHES "CygwinSource")
# when packaging source make sure the .build directory is not included
SET(CPACK_SOURCE_IGNORE_FILES
"/CVS/" "/\\.build/" "/\\.svn/" "\\.swp$" "\\.#" "/#" "~$")
endif(CPACK_GENERATOR MATCHES "CygwinSource")

View File

@ -19,39 +19,6 @@ MACRO(cpack_set_if_not_set name value)
ENDIF(NOT DEFINED "${name}")
ENDMACRO(cpack_set_if_not_set)
# create a new variable using var called
# _${var}_ESC_ where var is the name of a variable.
# the value of the new variable will have an extra
# level of escapes so that it will preserve escapes
# in the configured CPackConfig.cmake file.
MACRO(cpack_escape_variable var)
STRING(REPLACE "\\" "\\\\" var_value "${${var}}")
STRING(REPLACE "\"" "\\\"" var_value "${var_value}")
SET(_${var}_ESC_ "${var_value}")
ENDMACRO(cpack_escape_variable)
# do extra escapes on variables in CPACK_ESCAPE_VARIABLE
# create "special" value variables like this
# _(VARNAME)_ESC_ that store the extra escaped values for
# the varibles. This is because the original variables
# can not be used because this file gets included more
# than once and things would get double double escacped.
# (I think I want to escape...)
MACRO(cpack_escape_variables)
SET(_CPACK_OTHER_VARIABLES_)
GET_CMAKE_PROPERTY(res VARIABLES)
# first add extra escapes to the variables in CPACK_ESCAPE_VARIABLES
FOREACH(var ${res})
IF("xxx${var}" MATCHES "xxxCPACK")
list(FIND CPACK_ESCAPE_VARIABLES "${var}" _SHOULD_BE_ESCAPED)
if(_SHOULD_BE_ESCAPED GREATER -1)
cpack_escape_variable(${var})
endif(_SHOULD_BE_ESCAPED GREATER -1)
ENDIF("xxx${var}" MATCHES "xxxCPACK")
ENDFOREACH(var ${res})
ENDMACRO(cpack_escape_variables)
# Macro to encode variables for the configuration file
# find any varable that stars with CPACK and create a variable
# _CPACK_OTHER_VARIABLES_ that contains SET commands for
@ -62,17 +29,8 @@ MACRO(cpack_encode_variables)
GET_CMAKE_PROPERTY(res VARIABLES)
FOREACH(var ${res})
IF("xxx${var}" MATCHES "xxxCPACK")
# check for special escaped variables and use
# the escaped value instead of the actual value for
# the set.
list(FIND CPACK_ESCAPE_VARIABLES "${var}" _SHOULD_BE_ESCAPED)
if(_SHOULD_BE_ESCAPED GREATER -1)
SET(_CPACK_OTHER_VARIABLES_
"${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${_${var}_ESC_}\")")
else(_SHOULD_BE_ESCAPED GREATER -1)
SET(_CPACK_OTHER_VARIABLES_
"${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
endif(_SHOULD_BE_ESCAPED GREATER -1)
SET(_CPACK_OTHER_VARIABLES_
"${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
ENDIF("xxx${var}" MATCHES "xxxCPACK")
ENDFOREACH(var ${res})
ENDMACRO(cpack_encode_variables)
@ -148,7 +106,7 @@ if(NOT CPACK_GENERATOR)
else(CYGWIN)
if(APPLE)
option(CPACK_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
option(CPACK_OSXX11 "Enable to build OSX X11 packages" ON)
option(CPACK_OSXX11 "Enable to build OSX X11 packages" OFF)
else(APPLE)
option(CPACK_TZ "Enable to build TZ packages" ON)
endif(APPLE)
@ -227,50 +185,7 @@ cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "")
cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
# escape variables now before we do the icon define
# stuff
cpack_escape_variables()
# if CPACK_PACKAGE_ICON is set, then create a
# cpack variable that contains the NSIS code to define
# the CPACK_PACKAGE_ICON and MUI_HEADERIMAGE_BITMAP, this is used
# as an icon in the install wizard
# handle ESC_CPACK_PACKAGE_ICON version as well, that does
# not require extra escapes
if(CPACK_PACKAGE_ICON)
if(DEFINED _CPACK_PACKAGE_ICON_ESC_)
set(CPACK_NSIS_INSTALLER_ICON_CODE "
!define CPACK_PACKAGE_ICON \\\"@_CPACK_PACKAGE_ICON_ESC_@\\\"
!define MUI_HEADERIMAGE_BITMAP \\\"@_CPACK_PACKAGE_ICON_ESC_@\\\"
")
else(DEFINED _CPACK_PACKAGE_ICON_ESC_)
set(CPACK_NSIS_INSTALLER_ICON_CODE "
!define CPACK_PACKAGE_ICON \\\"@CPACK_PACKAGE_ICON@\\\"
!define MUI_HEADERIMAGE_BITMAP \\\"@CPACK_PACKAGE_ICON@\\\"
")
endif(DEFINED _CPACK_PACKAGE_ICON_ESC_)
endif(CPACK_PACKAGE_ICON)
if(CPACK_NSIS_MUI_ICON AND CPACK_NSIS_MUI_UNIICON)
if(DEFINED _CPACK_NSIS_MUI_ICON_ESC_)
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "
!define MUI_ICON \\\"@_CPACK_NSIS_MUI_ICON_ESC_@\\\"
!define MUI_UNICON \\\"@_CPACK_NSIS_MUI_UNIICON_ESC_@\\\"
")
else(DEFINED _CPACK_NSIS_MUI_ICON_ESC_)
set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "
!define MUI_ICON \\\"@CPACK_NSIS_MUI_ICON@\\\"
!define MUI_UNICON \\\"@CPACK_NSIS_MUI_UNIICON@\\\"
")
endif(DEFINED _CPACK_NSIS_MUI_ICON_ESC_)
endif(CPACK_NSIS_MUI_ICON AND CPACK_NSIS_MUI_UNIICON)
cpack_encode_variables()
configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
# Generate source file
@ -289,7 +204,6 @@ SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
cpack_escape_variables()
cpack_encode_variables()
configure_file("${cpack_source_input_file}"
"${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)

View File

@ -108,6 +108,26 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
<< " to " << nsisFileName << std::endl);
if(this->IsSet("CPACK_NSIS_MUI_ICON")
&& this->IsSet("CPACK_NSIS_MUI_UNIICON"))
{
std::string installerIconCode="!define MUI_ICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
installerIconCode += "\"\n";
installerIconCode += "!define MUI_UNICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
installerIconCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE",
installerIconCode.c_str());
}
if(this->IsSet("CPACK_PACKAGE_ICON"))
{
std::string installerIconCode = "!define MUI_HEADERIMAGE_BITMAP \"";
installerIconCode += this->GetOption("CPACK_PACKAGE_ICON");
installerIconCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE",
installerIconCode.c_str());
}
this->ConfigureFile(nsisInInstallOptions.c_str(),
nsisInstallOptions.c_str());
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());

View File

@ -15,15 +15,8 @@
=========================================================================*/
#include "cmCPackRPMGenerator.h"
#include "cmSystemTools.h"
#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmCPackLog.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx>
//----------------------------------------------------------------------
cmCPackRPMGenerator::cmCPackRPMGenerator()
{
@ -40,30 +33,11 @@ int cmCPackRPMGenerator::CompressFiles(const char* /*outFileName*/,
const std::vector<std::string>& /*files*/)
{
this->ReadListFile("CPackRPM.cmake");
// const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
if (!this->IsSet("RPMBUILD_EXECUTABLE"))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl);
return 0;
}
/* FIXME we should be able to stick with RPM naming scheme
* and not following CMake naming scheme?
const char* rpmFileName = this->GetOption("RPM_FILE_NAME");
const char* rpmDirectory = this->GetOption("RPM_DIRECTORY");
this->SetOption("CPACK_OUTPUT_FILE_NAME",rpmFileName);
std::string rpmFilePath;
rpmFilePath += rpmDirectory;
rpmFilePath += "/";
rpmFilePath += rpmFileName;
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",rpmFilePath.c_str());
*/
// this->SetOption("CPACK_OUTPUT_FILE_PATH",rpmFilePath);
//FIXME I think we should split CPackRPM.cmake into (at least)
// 2 differents files
return 1;
}