set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBUGINFO RELWITHASSERT MINSIZEREL PROFILE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
-set(CPACK_PACKAGE_NAME "gromacs")
-set(CPACK_PACKAGE_VERSION_MAJOR ${GMX_VERSION_MAJOR})
-set(CPACK_PACKAGE_VERSION_MINOR ${GMX_VERSION_MINOR})
-set(CPACK_PACKAGE_VERSION_PATCH ${GMX_VERSION_PATCH})
-set(CPACK_PACKAGE_VERSION ${GMX_VERSION_STRING})
-set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
-set(CPACK_PACKAGE_VENDOR "gromacs.org")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Gromacs - a toolkit for high-performance molecular simulation")
-set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/admin/InstallWelcome.txt")
-# Its GPL/LGPL, so they do not have to agree to a license for mere usage, but some installers require this...
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
-set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/admin/InstallInfo.txt")
-set(CPACK_SOURCE_IGNORE_FILES "\\\\.isreposource$;\\\\.git/;\\\\.gitignore$;\\\\.gitattributes;")
-set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/CPackInit.cmake")
-# CPack source archives include only the directories we list here.
-# This variable is a list of pairs of names of source and destination
-# directories. Most of these are used for content GROMACS generates as
-# part of the configuration or build.
-set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR};/;${CMAKE_BINARY_DIR}/src/programs/completion;src/programs/completion;${CMAKE_BINARY_DIR}/docs/man/man1;docs/man/man1;${CMAKE_BINARY_DIR}/docs/man/man7;docs/man/man7;${CMAKE_BINARY_DIR}/docs/old-html/final;docs/old-html/final;${CMAKE_BINARY_DIR}/docs/install-guide/final;/")
-set(CPACK_PACKAGE_CONTACT "gmx-users@gromacs.org")
-#set(CPACK_GMX_BUILD_HELP "${GMX_BUILD_HELP}") #No longer works because GMX_BUILD_HELP is defined later.
-
-#must come after all cpack settings!
-include(CPack)
# Set a default valgrind suppression file.
# This unfortunately needs to duplicate information from CTest to work as
"File that contains suppressions for the memory checker")
include(CTest)
+include(gmxCPackUtilities)
+gmx_cpack_init()
+
# Variables that accumulate stuff influencing the installed headers
set(INSTALLED_HEADER_INCLUDE_DIRS "")
set(INSTALLED_HEADER_DEFINITIONS "")
add_subdirectory(tests)
endif()
+gmx_cpack_write_config()
+
# Issue a warning if NVIDIA GPUs were detected, but CUDA was not found.
# Don't bother the user after the first configure pass.
if ((CUDA_NOTFOUND_AUTO AND GMX_DETECT_GPU_AVAILABLE) AND NOT GMX_GPU_DETECTION_DONE)
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-#TODO: add check that source doesn't contain any untracked files
-if(NOT CPACK_INSTALL_CMAKE_PROJECTS) #building source package
+set(BUILDING_SOURCE_PACKAGE OFF)
+# The essential difference in building a source package is that install() rules
+# from the CMake project are not considered when deciding what to package.
+# Instead, only the listed directories are packaged (and the listed directories
+# contain the source tree).
+if (NOT CPACK_INSTALL_CMAKE_PROJECTS)
+ set(BUILDING_SOURCE_PACKAGE ON)
+endif()
+
+if (BUILDING_SOURCE_PACKAGE)
+ # TODO: add check that source doesn't contain any untracked files
get_filename_component(CMAKE_BINARY_DIR ${CPACK_OUTPUT_CONFIG_FILE} PATH)
+ # TODO: The list could be generated at the same time as the list of
+ # directories to include to keep the probe file names at the same place.
+ # And this does not detect if things have been built in the past, but are
+ # outdated.
if (NOT EXISTS "${CMAKE_BINARY_DIR}/docs/man/man1/gmx-view.1" OR
NOT EXISTS "${CMAKE_BINARY_DIR}/docs/install-guide/final/INSTALL" OR
NOT EXISTS "${CMAKE_BINARY_DIR}/docs/old-html/final/online.html" OR
"GMX_BUILD_HELP=ON to automatically build the HTML parts.")
endif()
else()
- # TODO: Make this work again.
- #if (NOT CPACK_GMX_BUILD_HELP)
- # message(WARNING
- # "To create a complete binary package, bash completions, and "
- # "man and HTML pages need to be generated. "
- # "You need to configure with GMX_BUILD_HELP=ON to include all "
- # "in the binary package.")
- # # Building the man, html, ... targets is not sufficient because than the
- # # install is still not done.
- #endif()
+ # TODO: If GMX_BUILD_HELP is AUTO, it may happen that the generation fails,
+ # and things are silently left out.
+ # Also, it is currently impossible to get these files into the binary
+ # package for cross-compilation. However, binary packages are not
+ # currently used much, either...
+ if (NOT CPACK_GMX_BUILD_HELP)
+ message(WARNING
+ "To create a complete binary package, bash completions, and "
+ "man and HTML pages need to be generated. "
+ "You need to configure with GMX_BUILD_HELP=ON to include all "
+ "in the binary package.")
+ # Building the man, html, ... targets is not sufficient because than the
+ # install is still not done.
+ endif()
endif()
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2014, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+# Helper functions to encapsulate and modularize usage of CPack
+#
+# This file is intended to be the only place that directly sets CPack variables
+# (in gmx_cpack_write_config()), and other parts of the build system should
+# only call the functions declared here to set up the packaging.
+
+# Initialize the machinery that collects CPack information during other
+# build system generation
+#
+# This function should be called before other functions from this file.
+function (gmx_cpack_init)
+ # Add the source tree to the source package.
+ # If we would not set CPACK_SOURCE_INSTALLED_DIRECTORIES, this is what
+ # CPack would set as default.
+ set_property(GLOBAL PROPERTY GMX_CPACK_SOURCE_INSTALLED_DIRECTORIES
+ ${PROJECT_SOURCE_DIR} /)
+endfunction()
+
+# Add a generated directory to be included in the source package.
+#
+# Usage:
+# gmx_cpack_add_generated_source_directory(<dir> [DESTINATION <dest>])
+#
+# <dir> Name of directory to include.
+# Relative paths are interpreted relative to current build dir.
+# <dest> Path in the source package where files from <dir> will be put.
+# If not set, the files are put in the corresponding location in
+# the source tree.
+#
+# By default, CPack source archives includes all files from the source tree.
+# This function adds a directory from the build tree to be packaged into the
+# source archive. These are used for content GROMACS generates as part of the
+# configuration or build.
+# The values end up in CPACK_SOURCE_INSTALLED_DIRECTORIES, which is a list of
+# pairs of names of source and destination directories.
+function (gmx_cpack_add_generated_source_directory DIR)
+ include(CMakeParseArguments)
+ set(_one_value_args DESTINATION)
+ cmake_parse_arguments(ARG "" "${_one_value_args}" "" ${ARGN})
+ if (ARG_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}")
+ endif()
+ set(_dir ${DIR})
+ if (NOT IS_ABSOLUTE ${_dir})
+ set(_dir ${CMAKE_CURRENT_BINARY_DIR}/${_dir})
+ endif()
+ if (ARG_DESTINATION)
+ set(_dest ${ARG_DESTINATION})
+ else()
+ file(RELATIVE_PATH _dest ${PROJECT_BINARY_DIR} ${_dir})
+ endif()
+ set_property(GLOBAL APPEND PROPERTY GMX_CPACK_SOURCE_INSTALLED_DIRECTORIES
+ ${_dir} ${_dest})
+endfunction()
+
+# Write CPack configuration files
+#
+# This function should be called at the end of the main CMakeLists.txt, after
+# all other calls to functions in this file.
+# CPack also automatically populates the list of components based on components
+# used in installation rules, so it should come after all install() commands.
+function (gmx_cpack_write_config)
+ # Set basic package information.
+ set(CPACK_PACKAGE_NAME "gromacs")
+ set(CPACK_PACKAGE_VENDOR "gromacs.org")
+ set(CPACK_PACKAGE_CONTACT "gmx-users@gromacs.org")
+ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+ "Gromacs - a toolkit for high-performance molecular simulation")
+ # Set version info.
+ set(CPACK_PACKAGE_VERSION_MAJOR ${GMX_VERSION_MAJOR})
+ set(CPACK_PACKAGE_VERSION_MINOR ${GMX_VERSION_MINOR})
+ set(CPACK_PACKAGE_VERSION_PATCH ${GMX_VERSION_PATCH})
+ set(CPACK_PACKAGE_VERSION ${GMX_VERSION_STRING})
+ # Add various text resources for some installers.
+ set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/admin/InstallWelcome.txt")
+ # Its GPL/LGPL, so they do not have to agree to a license for mere usage,
+ # but some installers require this...
+ set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
+ set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/admin/InstallInfo.txt")
+
+ # Our custom config file that is run by CPack for each generator, used to
+ # check for prerequisites of the packaging.
+ set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_SOURCE_DIR}/CPackInit.cmake")
+
+ # Settings specific to source packages.
+ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
+ set(CPACK_SOURCE_IGNORE_FILES
+ "\\\\.isreposource$;\\\\.git/;\\\\.gitignore$;\\\\.gitattributes;")
+ # Get the list of directories added with gmx_cpack_add_generated_source_directory()
+ get_property(CPACK_SOURCE_INSTALLED_DIRECTORIES
+ GLOBAL PROPERTY GMX_CPACK_SOURCE_INSTALLED_DIRECTORIES)
+
+ # Propagate additional values for CPackInit.cmake to use.
+ # CPack includes all variables starting with CPACK_ into the generated
+ # config files that are included by CPack.
+ set(CPACK_GMX_BUILD_HELP "${GMX_BUILD_HELP}")
+
+ # Generate the CPack configuration files.
+ include(CPack)
+endfunction()