From 88dc658b890c3a8516463cbd105cbc1c1a8d16f4 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Fri, 4 Jul 2014 16:05:27 +0200 Subject: [PATCH] Fix and document issues with template.cpp Boost is a requirement for the template, so the FindGROMACS.cmake needs machinery to deal with that. It will now find the Boost internal to GROMACS. pkg-config generally helps (if available and GMXRC is sourced), and that use is now documented in the README. Finding the GROMACS libraries and headers is also a requirement. This now works whether or not the user has sourced GMXRC or has pkg-config installed. The user can over-ride this with CMAKE_PREFIX_PATH if they want to. The template needs to use the same compiler and compiler flags for post-C++98 support, and this is now documented in the README. In master branch, some of these issues are side-stepped, so take due care when merging. Fixes #1554 Change-Id: Id30cf5149ead4a3f719499e37776a00f08309afc --- share/template/README | 25 +++++++++++++++++++++++- share/template/cmake/FindGROMACS.cmakein | 20 +++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/share/template/README b/share/template/README index 535db079bc..dc25c57bfa 100644 --- a/share/template/README +++ b/share/template/README @@ -6,12 +6,35 @@ The CMakelist.txt can be used together with cmake to build the template program: $ source /path/to/GMXRC $ cmake /path/to/template +Alternatively, setting CMAKE_PREFIX_PATH will direct cmake +to find a particular GROMACS installation. -The Makefile.pkg can be used if cmake is unavailble. It +The Makefile.pkg can be used if cmake is unavailable. It makes use of pkg-config only to build the template program: $ source /path/to/GMXRC $ make -f Makefile.pkg +You will need to make sure that you use a sufficiently similar C++ +compiler and C++ Standard Library as the one that was used for +compiling GROMACS, preferably the same one. If you used any system +libraries (e.g. Boost, FFTW, BLAS, LAPACK) when installing GROMACS, +then you will need make them available to the template build system +also. The easiest way to do this is to have pkg-config installed on +your system, and to source GMXRC from the GROMACS installation before +you attempt to configure the template. A subset of Boost is supposed +to be installed with GROMACS, but currently the automatic machinery +does not detect that installation, so you may need to install Boost +(headers only) in order to use the GROMACS template program. + +If the compiler used for GROMACS was capable of some C++11 features +then, by default, those will be required for compiling the +template. To make that work, you can either configure GROMACS with +$ cmake -DGMX_CXX11=off +or configure the template with the appropriate +$ cmake -DCMAKE_CXX_FLAGS="-flag-for-your-compiler" +You can find out the necessary flags from your compiler's documentation, +or by inspecting the src/buildinfo.h file in the GROMACS build tree. + ---------------------------------------------------------- If you are reading this in the distribution directory, diff --git a/share/template/cmake/FindGROMACS.cmakein b/share/template/cmake/FindGROMACS.cmakein index 84a0fa6ed1..53fec71361 100644 --- a/share/template/cmake/FindGROMACS.cmakein +++ b/share/template/cmake/FindGROMACS.cmakein @@ -90,7 +90,7 @@ if (GROMACS_LIBRARY) list(REMOVE_ITEM PC_GROMACS_LIBRARIES ${GROMACS_LIBRARY_NAME}) foreach (LIB ${PC_GROMACS_LIBRARIES}) find_library(GROMACS_${LIB} NAMES ${LIB} - HINTS ${PC_GROMACS_LIBRARY_DIRS} @CMAKE_INSTALL_PREFIX@/@INCL_INSTALL_DIR@) + HINTS ${PC_GROMACS_LIBRARY_DIRS} @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@) list(APPEND GMX_DEP_LIBRARIES ${GROMACS_${LIB}}) unset(GROMACS_${LIB} CACHE) endforeach(LIB) @@ -139,12 +139,12 @@ set(GROMACS_VERSION_STRING "${GROMACS_MAJOR_VERSION}.${GROMACS_MINOR_VERSION}.${ if ("${GROMACS_PKG}" MATCHES "libgmx") if (${GROMACS_VERSION} EQUAL 40000) - find_path(GROMACS_INCLUDE_DIR tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) + find_path(GROMACS_INCLUDE_DIR tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS} @CMAKE_INSTALL_PREFIX@/@INCL_INSTALL_DIR@) else(${GROMACS_VERSION} EQUAL 40000) - find_path(GROMACS_INCLUDE_DIR gromacs/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) + find_path(GROMACS_INCLUDE_DIR gromacs/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS} @CMAKE_INSTALL_PREFIX@/@INCL_INSTALL_DIR@) endif(${GROMACS_VERSION} EQUAL 40000) elseif("${GROMACS_PKG}" MATCHES "libgromacs") - find_path(GROMACS_INCLUDE_DIR gromacs/version.h HINTS ${PC_GROMACS_INCLUDE_DIRS}) + find_path(GROMACS_INCLUDE_DIR gromacs/version.h HINTS ${PC_GROMACS_INCLUDE_DIRS} @CMAKE_INSTALL_PREFIX@/@INCL_INSTALL_DIR@) endif("${GROMACS_PKG}" MATCHES "libgmx") set(GROMACS_LIBRARIES "${GROMACS_LIBRARY};${GROMACS_DEP_LIBRARIES}" ) @@ -153,6 +153,18 @@ if (PC_GROMACS_INCLUDE_DIRS) list(APPEND GROMACS_INCLUDE_DIRS ${PC_GROMACS_INCLUDE_DIRS}) endif(PC_GROMACS_INCLUDE_DIRS) +if(NOT ${GROMACS_MAJOR_VERSION} LESS 5) + include(CheckIncludeFile) + # Let find_package find the subset of Boost installed with GROMACS + set(BOOST_INCLUDEDIR ${GROMACS_INCLUDE_DIRS}/gromacs/external/boost) + find_package(Boost 1.44.0 REQUIRED) + if(Boost_FOUND) + list(APPEND GROMACS_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Boost not found, compiling the GROMACS template will not work") + endif() +endif() + include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set GROMACS_FOUND to TRUE # if all listed variables are TRUE -- 2.22.0