2006-06-12 22:21:36 +04:00
|
|
|
# Default output files will be CPackConfig.cmake and CPackSourceConfig.cmake.
|
|
|
|
# This can be overwritten with CPACK_OUTPUT_CONFIG_FILE and
|
|
|
|
# CPACK_SOURCE_OUTPUT_CONFIG_FILE.
|
|
|
|
|
2006-01-04 23:14:09 +03:00
|
|
|
# Pick a configuration file
|
|
|
|
SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
|
|
|
|
IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
|
|
|
|
SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
|
|
|
|
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
|
2006-04-15 21:02:18 +04:00
|
|
|
SET(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
|
|
|
|
IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
|
|
|
|
SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
|
|
|
|
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
|
2006-01-04 23:14:09 +03:00
|
|
|
|
|
|
|
# Macro for setting values if a user did not overwrite them
|
|
|
|
MACRO(cpack_set_if_not_set name value)
|
2006-01-09 19:26:31 +03:00
|
|
|
IF(NOT DEFINED "${name}")
|
2006-01-04 23:14:09 +03:00
|
|
|
SET(${name} "${value}")
|
2006-01-09 19:26:31 +03:00
|
|
|
ENDIF(NOT DEFINED "${name}")
|
2006-01-04 23:14:09 +03:00
|
|
|
ENDMACRO(cpack_set_if_not_set)
|
|
|
|
|
2006-04-15 21:02:18 +04:00
|
|
|
# Macro to encode variables for the configuration file
|
2006-06-16 05:43:59 +04:00
|
|
|
# find any varable that stars with CPACK and create a variable
|
|
|
|
# _CPACK_OTHER_VARIABLES_ that contains SET commands for
|
|
|
|
# each cpack variable. _CPACK_OTHER_VARIABLES_ is then
|
|
|
|
# used as an @ replacment in configure_file for the CPackConfig.
|
2006-04-15 21:02:18 +04:00
|
|
|
MACRO(cpack_encode_variables)
|
|
|
|
SET(_CPACK_OTHER_VARIABLES_)
|
|
|
|
GET_CMAKE_PROPERTY(res VARIABLES)
|
|
|
|
FOREACH(var ${res})
|
2007-10-29 15:11:44 +03:00
|
|
|
IF("xxx${var}" MATCHES "xxxCPACK")
|
2007-10-31 06:02:43 +03:00
|
|
|
SET(_CPACK_OTHER_VARIABLES_
|
|
|
|
"${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
|
2007-10-29 15:11:44 +03:00
|
|
|
ENDIF("xxx${var}" MATCHES "xxxCPACK")
|
2006-04-15 21:02:18 +04:00
|
|
|
ENDFOREACH(var ${res})
|
|
|
|
ENDMACRO(cpack_encode_variables)
|
|
|
|
|
2006-01-04 23:14:09 +03:00
|
|
|
# Set the package name
|
2006-04-10 21:44:39 +04:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
2006-01-04 23:14:09 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
|
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
|
2006-02-23 17:38:40 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION
|
|
|
|
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
2006-01-04 23:14:09 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
|
2006-01-10 02:20:02 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
2006-04-10 21:44:39 +04:00
|
|
|
"${CMAKE_PROJECT_NAME} built using CMake")
|
2006-02-28 22:18:13 +03:00
|
|
|
|
2006-01-10 02:20:02 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
|
|
|
|
"${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
|
2006-02-28 22:18:13 +03:00
|
|
|
cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE
|
|
|
|
"${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
|
|
|
|
cpack_set_if_not_set(CPACK_RESOURCE_FILE_README
|
|
|
|
"${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
|
|
|
|
cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
|
|
|
|
"${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2006-10-12 21:05:50 +04:00
|
|
|
cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
|
|
|
|
|
2006-03-01 23:00:07 +03:00
|
|
|
IF(CPACK_NSIS_MODIFY_PATH)
|
|
|
|
SET(CPACK_NSIS_MODIFY_PATH ON)
|
|
|
|
ENDIF(CPACK_NSIS_MODIFY_PATH)
|
|
|
|
|
2006-04-24 03:45:43 +04:00
|
|
|
SET(__cpack_system_name ${CMAKE_SYSTEM_NAME})
|
|
|
|
IF(${__cpack_system_name} MATCHES Windows)
|
|
|
|
IF(CMAKE_CL_64)
|
|
|
|
SET(__cpack_system_name win64)
|
|
|
|
ELSE(CMAKE_CL_64)
|
|
|
|
SET(__cpack_system_name win32)
|
|
|
|
ENDIF(CMAKE_CL_64)
|
|
|
|
ENDIF(${__cpack_system_name} MATCHES Windows)
|
|
|
|
cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
|
|
|
|
|
2006-01-04 23:14:09 +03:00
|
|
|
# <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
|
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
|
2008-03-27 03:12:17 +03:00
|
|
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
|
2006-02-23 17:38:40 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
|
|
|
|
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
|
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
|
|
|
|
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
|
2007-12-27 00:57:13 +03:00
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
|
|
|
|
cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true")
|
|
|
|
|
|
|
|
# always force to exactly "true" or "false" for CPack.Info.plist.in:
|
|
|
|
if(CPACK_PACKAGE_RELOCATABLE)
|
|
|
|
set(CPACK_PACKAGE_RELOCATABLE "true")
|
|
|
|
else(CPACK_PACKAGE_RELOCATABLE)
|
|
|
|
set(CPACK_PACKAGE_RELOCATABLE "false")
|
|
|
|
endif(CPACK_PACKAGE_RELOCATABLE)
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2007-08-03 23:26:30 +04:00
|
|
|
macro(cpack_check_file_exists file description)
|
|
|
|
if(NOT EXISTS "${file}")
|
|
|
|
message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
|
|
|
|
endif(NOT EXISTS "${file}")
|
|
|
|
endmacro(cpack_check_file_exists)
|
|
|
|
|
2006-02-28 22:18:13 +03:00
|
|
|
cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
|
|
|
|
cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
|
|
|
|
cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
|
|
|
|
cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2007-08-03 23:26:30 +04:00
|
|
|
macro(cpack_optional_append _list _cond _item)
|
|
|
|
if(${_cond})
|
|
|
|
set(${_list} ${${_list}} ${_item})
|
|
|
|
endif(${_cond})
|
|
|
|
endmacro(cpack_optional_append _list _cond _item)
|
|
|
|
|
|
|
|
# Provide options to choose generators
|
|
|
|
# we might check here if the required tools for the generates exist
|
|
|
|
# and set the defaults according to the results
|
|
|
|
if(NOT CPACK_GENERATOR)
|
|
|
|
if(UNIX)
|
|
|
|
if(CYGWIN)
|
2008-04-18 01:23:21 +04:00
|
|
|
option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
|
2007-08-03 23:26:30 +04:00
|
|
|
else(CYGWIN)
|
|
|
|
if(APPLE)
|
2008-04-18 01:23:21 +04:00
|
|
|
option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
|
|
|
|
option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
|
2007-08-03 23:26:30 +04:00
|
|
|
else(APPLE)
|
2008-04-18 01:23:21 +04:00
|
|
|
option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
|
2007-08-03 23:26:30 +04:00
|
|
|
endif(APPLE)
|
2008-04-18 01:23:21 +04:00
|
|
|
option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
|
|
|
|
option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
|
|
|
|
option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" ON)
|
|
|
|
option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
|
|
|
|
option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
|
|
|
|
option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
|
2007-08-03 23:26:30 +04:00
|
|
|
endif(CYGWIN)
|
|
|
|
else(UNIX)
|
2008-04-18 01:23:21 +04:00
|
|
|
option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
|
|
|
|
option(CPACK_BINARY_ZIP "Enable to build ZIP packages" ON)
|
2007-08-03 23:26:30 +04:00
|
|
|
endif(UNIX)
|
|
|
|
|
2008-04-18 01:23:21 +04:00
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
|
|
|
|
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
|
2007-08-03 23:26:30 +04:00
|
|
|
|
|
|
|
endif(NOT CPACK_GENERATOR)
|
|
|
|
|
|
|
|
# Provide options to choose source generators
|
|
|
|
if(NOT CPACK_SOURCE_GENERATOR)
|
|
|
|
if(UNIX)
|
|
|
|
if(CYGWIN)
|
|
|
|
option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
|
|
|
|
else(CYGWIN)
|
|
|
|
option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
|
|
|
|
option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
|
|
|
|
option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
|
|
|
|
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
|
|
|
|
endif(CYGWIN)
|
|
|
|
else(UNIX)
|
|
|
|
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
|
|
|
|
endif(UNIX)
|
|
|
|
|
|
|
|
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
|
|
|
|
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
|
|
|
|
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
|
|
|
|
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
|
|
|
|
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
|
|
|
|
endif(NOT CPACK_SOURCE_GENERATOR)
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2007-09-01 00:27:08 +04:00
|
|
|
# mark the above options as advanced
|
2008-04-18 01:23:21 +04:00
|
|
|
mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11
|
|
|
|
CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2
|
|
|
|
CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ
|
|
|
|
CPACK_BINARY_NSIS CPACK_BINARY_ZIP
|
2007-09-01 00:27:08 +04:00
|
|
|
CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ
|
|
|
|
CPACK_SOURCE_TZ CPACK_SOURCE_ZIP)
|
|
|
|
|
2006-01-04 23:14:09 +03:00
|
|
|
# Set some other variables
|
2006-04-10 19:09:52 +04:00
|
|
|
cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
|
2006-04-14 16:58:13 +04:00
|
|
|
"${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
|
2006-04-10 21:44:39 +04:00
|
|
|
cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
|
2006-04-24 03:45:43 +04:00
|
|
|
cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
|
2006-04-15 21:02:18 +04:00
|
|
|
|
2006-04-30 04:01:34 +04:00
|
|
|
cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "@CPACK_PACKAGE_INSTALL_DIRECTORY@")
|
|
|
|
|
2006-06-12 22:21:36 +04:00
|
|
|
cpack_set_if_not_set(CPACK_OUTPUT_CONFIG_FILE
|
|
|
|
"${CMAKE_BINARY_DIR}/CPackConfig.cmake")
|
|
|
|
|
|
|
|
cpack_set_if_not_set(CPACK_SOURCE_OUTPUT_CONFIG_FILE
|
|
|
|
"${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
|
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
cpack_set_if_not_set(CPACK_SET_DESTDIR OFF)
|
2007-02-13 22:13:51 +03:00
|
|
|
cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
2007-10-22 19:40:07 +04:00
|
|
|
cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "")
|
2007-10-29 15:11:44 +03:00
|
|
|
cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
|
|
|
|
|
2007-10-23 01:16:33 +04:00
|
|
|
cpack_encode_variables()
|
2007-08-03 23:26:30 +04:00
|
|
|
configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2006-04-15 21:02:18 +04:00
|
|
|
# Generate source file
|
|
|
|
cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
|
|
|
|
"${CMAKE_SOURCE_DIR};/")
|
2006-04-24 03:45:43 +04:00
|
|
|
cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
|
2006-04-15 21:02:18 +04:00
|
|
|
cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
2008-03-27 03:12:17 +03:00
|
|
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
|
2006-04-15 21:02:18 +04:00
|
|
|
cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
|
2006-04-18 18:01:37 +04:00
|
|
|
"/CVS/;/\\\\\\\\.svn/;\\\\\\\\.swp$;\\\\\\\\.#;/#")
|
2006-04-15 21:02:18 +04:00
|
|
|
SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
|
|
|
|
SET(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
|
|
|
|
SET(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
|
|
|
|
SET(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
|
|
|
|
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
|
|
|
|
SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
|
2006-05-11 01:26:57 +04:00
|
|
|
SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
|
2006-02-27 18:58:20 +03:00
|
|
|
|
2006-04-15 21:02:18 +04:00
|
|
|
cpack_encode_variables()
|
2007-08-03 23:26:30 +04:00
|
|
|
configure_file("${cpack_source_input_file}"
|
2006-06-12 22:21:36 +04:00
|
|
|
"${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
|