[gmx-developers] cmake find modules for Gromacs

Christoph Junghans junghans at mpip-mainz.mpg.de
Mon Feb 28 15:00:09 CET 2011


Dear all,

we are in the process of moving the votca package from GNU Autotools to 
cmake. For that we have started writing a find modules for Gromacs. This 
would be useful to put it in share/template as well.

Question 1: Has anyone done something like this before?

In the case of linking to a shared library of gromacs, this is 
trivial(see below), due to the fact that the shared object contains all 
linking information.

The trouble starts in case of a static library build by autotools, 
because one needs to take care of the dependcies of e.g. libmd, namely 
libfftw3, libgsl and libxml2, where libxml2 and libgsl are even 
optional. This is mainly due to the different ways how cmake and 
autotools build a static library.

Example: 'nm libgmx.a | grep fftw' is empty for autotoools, but for 
cmake is is not empty, because cmake includes the fftw functions into 
the static libs.

Question 2: Is there any cmake guru around, to solve this issue 
consistently?

Cheers,

Christoph


PS: A very simple FindGMX.cmake for libgromacs

find_package(PkgConfig)
pkg_check_modules(PC_GROMACS_D libgromacs_d)
pkg_check_modules(PC_GROMACS libgromacs)

#prefer double over single
find_path(GMX_INCLUDE_DIR gromacs/legacyheaders/tpxio.h
   HINTS ${PC_GROMACS_D_INCLUDE_DIRS} ${PC_GROMACS_INCLUDE_DIRS})
find_library(GMX_LIBRARY NAMES gromacs_d gromacs
  HINTS ${PC_GROMACS_D_LIBRARY_DIRS} ${PC_GROMACS_LIBRARY_DIRS})

set(GMX_LIBRARIES ${GMX_LIBRARY} )
set(GMX_INCLUDE_DIRS ${GMX_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(GMX DEFAULT_MSG GMX_LIBRARY 
GMX_INCLUDE_DIR )

mark_as_advanced(GMX_INCLUDE_DIR GMX_LIBRARY )


http://www.vtk.org/Wiki/CMake:How_To_Find_Libraries#Writing_find_modules
-- 
Dr. Christoph Junghans
Max Planck Institute for Polymer Research
Theory Group
POBox 3148
D 55021 Mainz, Germany

Phone: +49 6131 379 335
Web: http://www.mpip-mainz.mpg.de/~junghans




More information about the gromacs.org_gmx-developers mailing list