Fix build of share/template when installed
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 1 Feb 2014 18:08:09 +0000 (20:08 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 6 Feb 2014 18:13:40 +0000 (19:13 +0100)
It is now possible to build the analysis tool template using the
Makefile.pkg and the CMakeLists.txt that are installed with it, at least
under some conditions.  FindGROMACS.cmake could probably be improved
further by using gromacs/version.h to detect the version for those
installations where it is present (4.6 and up); the current list of
functions is confusing (init_domdec_vsites, for example, already appears
in 4.6, but causes the detected version to be set to 5.0), and requires
extra maintenance for each release.

Remove obsolete Template.mak, which was used by autoconf to generate an
installed Makefile.

Change-Id: Ibcaa792b721db7fc9729710e36ace29bddbb82c3

CMakeLists.txt
share/template/CMakeLists.txt.template
share/template/Makefile.pkg
share/template/Template.mak [deleted file]
share/template/cmake/FindGROMACS.cmakein

index 7c7e2e437efd140d30c207f1806212ae49a10b35..9a3ce3c3ced4e570b9f3bcf5c3155f60fde9ed05 100644 (file)
@@ -761,6 +761,7 @@ install(FILES COPYING DESTINATION ${DATA_INSTALL_DIR} COMPONENT data)
 
 if(GMX_EXTERNAL_BOOST)
     include_directories(${Boost_INCLUDE_DIRS})
+    set(PKG_CFLAGS "${PKG_CFLAGS} -I${Boost_INCLUDE_DIRS}")
 else()
     include_directories(${CMAKE_SOURCE_DIR}/src/external/boost)
     # typeid not supported for minimal internal version
index 001dc8926e1820cd8c1d44a682fdd73e269259ed..0cc6dcdfba7edb81f4510f52b4b4fde679896275 100644 (file)
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8)
 
 project(template)
 
@@ -9,8 +9,6 @@ if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
 endif(NOT CMAKE_BUILD_TYPE)
 
-enable_language(C)
-
 option(GMX_DOUBLE "Use double precision" OFF)
 
 ########################################################################
@@ -20,7 +18,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
     STRING(REPLACE /MD /MT CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
     SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
     STRING(REPLACE /MD /MT CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
-    SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)   
+    SET(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING "" FORCE)
 ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
 
 ########################################################################
@@ -35,17 +33,12 @@ endif(GMX_DOUBLE)
 
 FIND_PACKAGE(GROMACS COMPONENTS ${LIBGROMACS} REQUIRED)
 message("GROMACS version ${GROMACS_VERSION_STRING} found")
-if ("${GROMACS_VERSION_STRING}" VERSION_LESS "4.6" OR "${GROMACS_VERSION_STRING}" VERSION_GREATER "4.99")
-  message(FATAL_ERROR "This template works only with GROMACS 4.6")
-endif ("${GROMACS_VERSION_STRING}" VERSION_LESS "4.6" OR "${GROMACS_VERSION_STRING}" VERSION_GREATER "4.99")
+if ("${GROMACS_VERSION_STRING}" VERSION_LESS "5.0")
+  message(FATAL_ERROR "This template works with GROMACS 5.0 (and possibly later versions)")
+endif()
 
 add_definitions( ${GROMACS_DEFINITIONS} )
 include_directories( ${GROMACS_INCLUDE_DIRS} )
 
-########################################################################
-# Specify install locations and which subdirectories to process        #
-########################################################################
-set(BIN_INSTALL_DIR  ${CMAKE_INSTALL_PREFIX}/bin)
-
-add_executable(template template.c)
+add_executable(template template.cpp)
 target_link_libraries(template ${GROMACS_LIBRARIES})
index e4788c4289900e52eb29df73dd8850d18aa651c0..84e9323ca72bf95303031438b4205342eb18233d 100644 (file)
@@ -1,4 +1,4 @@
-# This is a Gromacs 4.5 template makefile for your own utility programs using pkg-config.
+# This is a Gromacs template makefile for your own utility programs using pkg-config.
 #
 # Copy this file to whatever directory you are using for your own software
 #
@@ -9,7 +9,7 @@
 #change the name of the program here
 NAME=template
 
-#add extra c file to compile here
+#add extra c++ file(s) to compile here
 EXTRA_SRC=
 
 ###############################################################3
@@ -27,14 +27,15 @@ else
 endif
 
 #get CPPFLAGS and LDFLAGS from pkg-config
-CPPFLAGS=`pkg-config --cflags libgmx`
-LDFLAGS=`pkg-config --libs libgmx`
+CPPFLAGS=`pkg-config --cflags libgromacs`
+LDFLAGS=`pkg-config --libs libgromacs`
 
 #generate a list of object (.o) files
-OBJS=$(patsubst %.c,%.o,$(NAME).c $(EXTRA_SRC))
+OBJS=$(patsubst %.cpp,%.o,$(NAME).cpp $(EXTRA_SRC))
 
 #main program depend on all objects, rest is done by implicit rules
 $(NAME): $(OBJS)
+       $(CXX) $(LDFLAGS) -o $@ $^
 
 #clean up rule
 clean:
diff --git a/share/template/Template.mak b/share/template/Template.mak
deleted file mode 100644 (file)
index 1018f33..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# Generated automatically from Makefile.in by configure.
-#
-# This is a Gromacs 4.5 template makefile for your own utility programs.
-#
-# Copy this file to whatever directory you are using for your own
-# software and add more targets like the template one below.
-#
-# If you are using gmake it is relatively straightforward to add
-# an include based on environment variables (like previous Gromacs versions)
-# to select compiler flags and stuff automatically, but below it is static:
-#
-
-# Variables set by the configuration script:
-LIBS         = @LIBS@ 
-LDFLAGS      = @LDFLAGS@
-CFLAGS      = @CFLAGS@ 
-CC           = @CC@
-LD           = $(CC)
-
-# The real make targets - note that most make programs support
-# the shortcut $^ instead of listing all object files a second
-# time, but we cannot count on it...
-
-template:      template.o
-               $(LD) $(LDFLAGS) -o $@ template.o $(LIBS)
index f5da0ab1bd34eb9486be6e0a7207f55d2e1cd3ee..c8830815f20770e9829723d189dfad528ef2b822 100644 (file)
@@ -1,8 +1,8 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2009-2011, by the VOTCA Development Team (http://www.votca.org)
-# Copyright (c) 2012,2013, by the GROMACS development team, led by
+# Copyright (c) 2009-2011, by the VOTCA Development Team (http://www.votca.org).
+# Copyright (c) 2012,2013,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.
@@ -34,7 +34,7 @@
 # the research papers on the package. Check out http://www.gromacs.org.
 
 # - Finds parts of GROMACS
-# Find the native GROMACS compents headers and libraries.
+# Find the native GROMACS components headers and libraries.
 #
 #  GROMACS_INCLUDE_DIRS   - where to find GROMACS headers.
 #  GROMACS_LIBRARIES      - List of libraries when used by GROMACS.
@@ -144,11 +144,14 @@ if ("${GROMACS_PKG}" MATCHES "libgmx")
    find_path(GROMACS_INCLUDE_DIR gromacs/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS})
   endif(${GROMACS_VERSION} EQUAL 40000)
 elseif("${GROMACS_PKG}" MATCHES "libgromacs")
-  find_path(GROMACS_INCLUDE_DIR gromacs/legacyheaders/tpxio.h HINTS ${PC_GROMACS_INCLUDE_DIRS})
+  find_path(GROMACS_INCLUDE_DIR gromacs/version.h HINTS ${PC_GROMACS_INCLUDE_DIRS})
 endif("${GROMACS_PKG}" MATCHES "libgmx")
 
 set(GROMACS_LIBRARIES "${GROMACS_LIBRARY};${GROMACS_DEP_LIBRARIES}" )
 set(GROMACS_INCLUDE_DIRS ${GROMACS_INCLUDE_DIR} )
+if (PC_GROMACS_INCLUDE_DIRS)
+  list(APPEND GROMACS_INCLUDE_DIRS ${PC_GROMACS_INCLUDE_DIRS})
+endif(PC_GROMACS_INCLUDE_DIRS)
 
 include(FindPackageHandleStandardArgs)
 # handle the QUIETLY and REQUIRED arguments and set GROMACS_FOUND to TRUE