[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 



PS: A very simple FindGMX.cmake for libgromacs

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
find_library(GMX_LIBRARY NAMES gromacs_d gromacs


# 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 

mark_as_advanced(GMX_INCLUDE_DIR GMX_LIBRARY )

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