\verb+-DGMX_BUILD_MDRUN_ONLY=ON+, which will build a cut-down version
of \verb+libgromacs+ and/or the \verb+mdrun+ binary (according to
whether shared or static). Naturally, now \verb+make install+ acts
-only those binaries.
+only those binaries. By default, a fresh build tree with this variable
+set will default to building statically, because this is generally a
+good idea for the targets for which an mdrun-only build is
+desirable. If you re-use a build tree and change to the mdrun-only
+build, then you will inherit the setting for \verb+BUILD_SHARED_LIBS+
+from the old build, and will be warned that you may wish to manage
+\verb+BUILD_SHARED_LIBS+ yourself.
\subsection{Installing \gromacs{}}
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-# Manage the Gromacs shared librar setup.
+# Manage the Gromacs shared library setup.
########################################################################
# Shared/static library settings
########################################################################
# Determine the defaults (this block has no effect if the variables have
# already been set)
-if(APPLE OR CYGWIN OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux|.*BSD")
+if((APPLE OR CYGWIN OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux|.*BSD") AND NOT GMX_BUILD_MDRUN_ONLY)
# Maybe Solaris should be here? Patch this if you know!
SET(SHARED_LIBS_DEFAULT ON)
elseif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "BlueGene")
# Declare the user-visible options
option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic e.g. with MPI, or on some HPC systems)" ${SHARED_LIBS_DEFAULT})
+if(BUILD_SHARED_LIBS AND GMX_BUILD_MDRUN_ONLY)
+ message(WARNING "Both BUILD_SHARED_LIBS and GMX_BUILD_MDRUN_ONLY are set. Generally, an mdrun-only build should prefer to use static libraries, which is the default if you make a fresh build tree. You may be re-using an old build tree, and so may wish to set BUILD_SHARED_LIBS=off yourself.")
+endif()
+
if (UNIX)
set(GMX_PREFER_STATIC_LIBS_DESCRIPTION
"When finding libraries prefer static archives (it will only work if static versions of external dependencies are available and found)")