# 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}") #Works even though GMX_BUILD_HELP is defined later because it is off by default.
+#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)
include_directories(${COREWRAP_INCLUDE_DIR})
endif()
-option(GMX_BUILD_HELP "Build man pages, HTML help, and completions automatically (requires that compiled binaries can be executed on the build host)" OFF)
+# Value of AUTO tries to generate things, but will only produce warnings if
+# that fails.
+set(build_help_default AUTO)
+if (SOURCE_IS_SOURCE_DISTRIBUTION)
+ set(build_help_default OFF)
+endif()
+gmx_option_trivalue(GMX_BUILD_HELP "Build man pages, HTML help, and completions automatically (requires that compiled binaries can be executed on the build host)" ${build_help_default})
mark_as_advanced(GMX_BUILD_HELP)
if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND BUILD_IS_INSOURCE)
message(FATAL_ERROR
- "Rebuilding HTML and man pages is not supported for in-source "
- "builds from a source distribution. "
+ "Rebuilding HTML and man pages or shell completions is not supported "
+ "for in-source builds from a source distribution. "
"Set GMX_BUILD_HELP=OFF or do an out-of-source build to proceed.")
endif()
"GMX_BUILD_HELP=ON to automatically build the HTML parts.")
endif()
else()
- 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: 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()
endif()
string(REPLACE "[built-in]" "" _allowed "${ARGN}")
# Set the cache properties
- set(${NAME} ${DEFAULT} CACHE STRING ${_description})
+ set(${NAME} ${DEFAULT} CACHE STRING "${_description}")
set_property(CACHE ${NAME} PROPERTY STRINGS ${_allowed})
# Check that the value is one of the allowed
message(FATAL_ERROR "Invalid value for ${NAME}: ${${NAME}}")
endfunction()
+# Declares a cache variable with ON/OFF/AUTO values
+#
+# Usage:
+# gmx_option_trivalue(VAR "Description" DEFAULT)
+#
+# Output:
+# VAR is created in the cache, and the caller can assume that the value is
+# always one of ON/OFF/AUTO. Additionally, VAR_AUTO is set if value is AUTO,
+# and VAR_FORCE is set if value is ON.
+# These make it convenient to check for any combination of states with simple
+# if() statements (simple if(VAR) matches AUTO and ON).
+function(GMX_OPTION_TRIVALUE NAME DESCRIPTION DEFAULT)
+ set(_description "${DESCRIPTION}. ON/OFF/AUTO")
+ set(${NAME} ${DEFAULT} CACHE STRING "${_description}")
+ set_property(CACHE ${NAME} PROPERTY STRINGS ON OFF AUTO)
+
+ set(${NAME}_AUTO OFF)
+ set(${NAME}_FORCE OFF)
+ string(TOUPPER "${${NAME}}" ${NAME})
+ if ("${NAME}" STREQUAL "AUTO")
+ set(${NAME}_AUTO ON)
+ elseif (${NAME})
+ set(${NAME}_FORCE ON)
+ set(${NAME} ON)
+ else()
+ set(${NAME} OFF)
+ endif()
+ # Always provide the sanitized value to the caller
+ set(${NAME} "${${NAME}}" PARENT_SCOPE)
+ set(${NAME}_AUTO "${${NAME}_AUTO}" PARENT_SCOPE)
+ set(${NAME}_FORCE "${${NAME}_FORCE}" PARENT_SCOPE)
+endfunction()
+
# Hides or shows a cache value based on conditions
#
# Usage:
--- /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.
+
+if (NOT DEFINED GMX_EXECUTABLE OR NOT DEFINED SOURCE_DIR)
+ message(FATAL_ERROR "Required input parameter not set")
+endif()
+
+file(MAKE_DIRECTORY man1)
+file(MAKE_DIRECTORY man7)
+file(COPY ${SOURCE_DIR}/man7/gromacs.7.in DESTINATION man7/)
+execute_process(
+ COMMAND ${GMX_EXECUTABLE} -quiet help -export man
+ RESULT_VARIABLE exitcode)
+if (exitcode)
+ # Ensure that no partial output is left behind.
+ file(REMOVE_RECURSE man1)
+ file(REMOVE man7/gromacs.7)
+ if (ERRORS_ARE_FATAL)
+ message(FATAL_ERROR
+ "Failed to generate man pages. "
+ "Set GMX_BUILD_HELP=OFF if you want to skip them.\n"
+ "Error/exit code: ${exitcode}")
+ else()
+ message(
+ "Failed to generate man pages, will build GROMACS without. "
+ "Set GMX_BUILD_HELP=OFF if you want to skip this notification and "
+ "warnings during installation.")
+ endif()
+endif()
include(gmxCustomCommandUtilities)
-gmx_add_custom_output_target(man OUTPUT STAMP
- COMMAND ${CMAKE_COMMAND} -E make_directory man1
- COMMAND ${CMAKE_COMMAND} -E make_directory man7
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/man7/gromacs.7.in" man7/
- COMMAND gmx -quiet help -export man
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS gmx ${CMAKE_CURRENT_SOURCE_DIR}/man7/gromacs.7.in
- COMMENT "Generating man pages")
-
set(MAN_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (GMX_BUILD_HELP)
+ gmx_add_custom_output_target(man OUTPUT STAMP
+ COMMAND ${CMAKE_COMMAND}
+ -D GMX_EXECUTABLE=$<TARGET_FILE:gmx>
+ -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D ERRORS_ARE_FATAL=${GMX_BUILD_HELP_FORCE}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/BuildManPages.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS gmx
+ ${CMAKE_CURRENT_SOURCE_DIR}/man7/gromacs.7.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/BuildManPages.cmake
+ COMMENT "Generating man pages")
set_target_properties(man PROPERTIES EXCLUDE_FROM_ALL OFF)
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "man1;man7/gromacs.7")
if (SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_HELP)
install(FILES ${MAN_PAGE_DIR}/man7/gromacs.7
DESTINATION ${MAN_INSTALL_DIR}/man7
- COMPONENT man)
+ COMPONENT man OPTIONAL)
install(DIRECTORY ${MAN_PAGE_DIR}/man1
DESTINATION ${MAN_INSTALL_DIR}
- COMPONENT man)
+ COMPONENT man OPTIONAL)
endif()
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-if (NOT DEFINED OUTPUT_DIR OR NOT DEFINED SOURCE_HTML_DIR)
+if (NOT DEFINED GMX_EXECUTABLE OR NOT DEFINED OUTPUT_DIR OR NOT DEFINED SOURCE_HTML_DIR)
message(FATAL_ERROR "Required input parameter not set")
endif()
-function(PRE_EXPORT_ACTIONS)
- file(MAKE_DIRECTORY ${OUTPUT_DIR})
- file(MAKE_DIRECTORY ${OUTPUT_DIR}/programs)
- file(COPY ${SOURCE_HTML_DIR}/header.html.in DESTINATION .)
- file(COPY ${SOURCE_HTML_DIR}/footer.html DESTINATION .)
- file(COPY ${SOURCE_HTML_DIR}/links.dat DESTINATION .)
-endfunction()
+file(MAKE_DIRECTORY ${OUTPUT_DIR})
+file(MAKE_DIRECTORY ${OUTPUT_DIR}/programs)
+file(COPY ${SOURCE_HTML_DIR}/header.html.in DESTINATION .)
+file(COPY ${SOURCE_HTML_DIR}/footer.html DESTINATION .)
+file(COPY ${SOURCE_HTML_DIR}/links.dat DESTINATION .)
+
+# This is generated by gmx help -export html
+set(HEADER_FILE header.html)
-function(POST_EXPORT_ACTIONS)
- # This is generated by gmx help -export html
- set(HEADER_FILE header.html)
- set(FOOTER_FILE ${SOURCE_HTML_DIR}/footer.html)
- file(READ ${HEADER_FILE} HEADER_TEXT)
- file(READ ${FOOTER_FILE} FOOTER_TEXT)
- set(_title_re "[Tt][Ii][Tt][Ll][Ee]")
+execute_process(
+ COMMAND ${GMX_EXECUTABLE} -quiet help -export html
+ RESULT_VARIABLE exitcode)
+if (exitcode)
+ # Ensure that no partial output is left behind.
+ file(REMOVE_RECURSE ${OUTPUT_DIR})
+ file(REMOVE ${HEADER_FILE})
+ message(FATAL_ERROR
+ "Failed to generate HTML help. "
+ "Set GMX_BUILD_HELP=OFF or GMX_BUILD_HELP=AUTO if you want to skip them.\n"
+ "Error/exit code: ${exitcode}")
+endif()
- function(CREATE_HTML_FILE SOURCE_FILE ROOTPATH)
- file(RELATIVE_PATH _rel_path ${SOURCE_HTML_DIR} ${SOURCE_FILE})
- file(READ ${SOURCE_FILE} _content)
- string(REGEX REPLACE "^ *<${_title_re}>(.*)</${_title_re}>\n" "" _content "${_content}")
- set(TITLE "${CMAKE_MATCH_1}")
- string(CONFIGURE "${HEADER_TEXT}" _header @ONLY)
- set(_content "${_header}${_content}${FOOTER_TEXT}")
- file(WRITE ${OUTPUT_DIR}/${_rel_path} "${_content}")
- endfunction()
+set(FOOTER_FILE ${SOURCE_HTML_DIR}/footer.html)
+file(READ ${HEADER_FILE} HEADER_TEXT)
+file(READ ${FOOTER_FILE} FOOTER_TEXT)
+set(_title_re "[Tt][Ii][Tt][Ll][Ee]")
- create_html_file(${SOURCE_HTML_DIR}/online.html "")
- file(COPY ${SOURCE_HTML_DIR}/images DESTINATION ${OUTPUT_DIR})
- file(MAKE_DIRECTORY ${OUTPUT_DIR}/online)
- file(COPY ${SOURCE_HTML_DIR}/online/style.css DESTINATION ${OUTPUT_DIR}/online)
- file(GLOB _source_files ${SOURCE_HTML_DIR}/online/*.html)
- foreach(_file ${_source_files})
- create_html_file(${_file} "../")
- endforeach()
+function(CREATE_HTML_FILE SOURCE_FILE ROOTPATH)
+ file(RELATIVE_PATH _rel_path ${SOURCE_HTML_DIR} ${SOURCE_FILE})
+ file(READ ${SOURCE_FILE} _content)
+ string(REGEX REPLACE "^ *<${_title_re}>(.*)</${_title_re}>\n" "" _content "${_content}")
+ set(TITLE "${CMAKE_MATCH_1}")
+ string(CONFIGURE "${HEADER_TEXT}" _header @ONLY)
+ set(_content "${_header}${_content}${FOOTER_TEXT}")
+ file(WRITE ${OUTPUT_DIR}/${_rel_path} "${_content}")
endfunction()
-if (STEP STREQUAL "PRE")
- pre_export_actions()
-elseif (STEP STREQUAL "POST")
- post_export_actions()
-else()
- message(FATAL_ERROR "Unknown parameter STEP=${STEP}")
-endif()
+create_html_file(${SOURCE_HTML_DIR}/online.html "")
+file(COPY ${SOURCE_HTML_DIR}/images DESTINATION ${OUTPUT_DIR})
+file(MAKE_DIRECTORY ${OUTPUT_DIR}/online)
+file(COPY ${SOURCE_HTML_DIR}/online/style.css DESTINATION ${OUTPUT_DIR}/online)
+file(GLOB _source_files ${SOURCE_HTML_DIR}/online/*.html)
+foreach(_file ${_source_files})
+ create_html_file(${_file} "../")
+endforeach()
set(OUTPUT_DIR final)
-file(GLOB_RECURSE deps
- ${CMAKE_CURRENT_SOURCE_DIR}/images/*
- ${CMAKE_CURRENT_SOURCE_DIR}/*.html
- ${CMAKE_CURRENT_SOURCE_DIR}/*.css
- )
-list(APPEND deps
- ${CMAKE_CURRENT_SOURCE_DIR}/BuildHtmlHelp.cmake
- ${CMAKE_CURRENT_SOURCE_DIR}/header.html.in
- ${CMAKE_CURRENT_SOURCE_DIR}/links.dat
- )
-
-gmx_add_custom_output_target(html OUTPUT STAMP
- COMMAND ${CMAKE_COMMAND}
- -D SOURCE_HTML_DIR=${CMAKE_CURRENT_SOURCE_DIR}
- -D OUTPUT_DIR=${OUTPUT_DIR}
- -D STEP=PRE
- -P ${CMAKE_CURRENT_SOURCE_DIR}/BuildHtmlHelp.cmake
- COMMAND gmx -quiet help -export html
- COMMAND ${CMAKE_COMMAND}
- -D SOURCE_HTML_DIR=${CMAKE_CURRENT_SOURCE_DIR}
- -D OUTPUT_DIR=${OUTPUT_DIR}
- -D STEP=POST
- -P ${CMAKE_CURRENT_SOURCE_DIR}/BuildHtmlHelp.cmake
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS gmx ${deps}
- COMMENT "Generating HTML help")
-
set(HTML_PAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${OUTPUT_DIR})
if (GMX_BUILD_HELP)
- set_target_properties(html PROPERTIES EXCLUDE_FROM_ALL OFF)
+ # Unlike the man and completion targets, this target is not built
+ # automatically with GMX_BUILD_HELP=AUTO, since most people will not
+ # notice it missing.
+ file(GLOB_RECURSE deps
+ ${CMAKE_CURRENT_SOURCE_DIR}/images/*
+ ${CMAKE_CURRENT_SOURCE_DIR}/*.html
+ ${CMAKE_CURRENT_SOURCE_DIR}/*.css
+ )
+ list(APPEND deps
+ ${CMAKE_CURRENT_SOURCE_DIR}/BuildHtmlHelp.cmake
+ ${CMAKE_CURRENT_SOURCE_DIR}/header.html.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/links.dat
+ )
+
+ gmx_add_custom_output_target(html OUTPUT STAMP
+ COMMAND ${CMAKE_COMMAND}
+ -D GMX_EXECUTABLE=$<TARGET_FILE:gmx>
+ -D SOURCE_HTML_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ -D OUTPUT_DIR=${OUTPUT_DIR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/BuildHtmlHelp.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS gmx ${deps}
+ COMMENT "Generating HTML help")
+
+ if (GMX_BUILD_HELP_FORCE)
+ set_target_properties(html PROPERTIES EXCLUDE_FROM_ALL OFF)
+ endif()
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "${OUTPUT_DIR};header.html")
set(HTML_PAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_DIR})
endif()
-if (SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_HELP)
+if (SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_HELP_FORCE)
install(DIRECTORY ${HTML_PAGE_DIR}/
DESTINATION ${DATA_INSTALL_DIR}/html
COMPONENT html)
--- /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.
+
+if (NOT DEFINED GMX_EXECUTABLE)
+ message(FATAL_ERROR "Required input parameter not set")
+endif()
+
+file(MAKE_DIRECTORY completion)
+execute_process(
+ COMMAND ${GMX_EXECUTABLE} -quiet help -export completion
+ WORKING_DIRECTORY completion
+ RESULT_VARIABLE exitcode)
+if (exitcode)
+ # Ensure that no partial output is left behind.
+ file(REMOVE_RECURSE completion)
+ if (ERRORS_ARE_FATAL)
+ message(FATAL_ERROR
+ "Failed to generate shell completions. "
+ "Set GMX_BUILD_HELP=OFF if you want to skip the completions.\n"
+ "Error/exit code: ${exitcode}")
+ else()
+ message(
+ "Failed to generate shell completions, will build GROMACS without. "
+ "Set GMX_BUILD_HELP=OFF if you want to skip this notification and "
+ "warnings during installation.")
+ endif()
+endif()
include(gmxCustomCommandUtilities)
- gmx_add_custom_output_target(completion OUTPUT STAMP
- COMMAND ${CMAKE_COMMAND} -E make_directory completion
- COMMAND ${CMAKE_COMMAND} -E chdir completion
- $<TARGET_FILE:gmx> -quiet help -export completion
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS gmx
- COMMENT "Generating command-line completions for programs")
+ set(COMPLETION_DIR ${CMAKE_CURRENT_SOURCE_DIR}/completion)
# Using GMX_BUILD_HELP here is somewhat confusing, but the conditions when
# this can be done are exactly the same (ability to run the compiled
# binaries).
- set(COMPLETION_DIR ${CMAKE_CURRENT_SOURCE_DIR}/completion)
if (GMX_BUILD_HELP)
+ gmx_add_custom_output_target(completion OUTPUT STAMP
+ COMMAND ${CMAKE_COMMAND}
+ -D GMX_EXECUTABLE=$<TARGET_FILE:gmx>
+ -D ERRORS_ARE_FATAL=${GMX_BUILD_HELP_FORCE}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/BuildCompletions.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS gmx ${CMAKE_CURRENT_SOURCE_DIR}/BuildCompletions.cmake
+ COMMENT "Generating command-line completions for programs")
set_target_properties(completion PROPERTIES EXCLUDE_FROM_ALL OFF)
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "completion")
endif()
if (SOURCE_IS_SOURCE_DISTRIBUTION OR GMX_BUILD_HELP)
install(DIRECTORY ${COMPLETION_DIR}/
- DESTINATION ${BIN_INSTALL_DIR} COMPONENT runtime)
+ DESTINATION ${BIN_INSTALL_DIR} COMPONENT runtime OPTIONAL)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gmx-completion-${BINARY_NAME}.bash
"complete -o nospace -F _gmx_compl ${BINARY_NAME}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gmx-completion-${BINARY_NAME}.bash