2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2016, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 include(gmxOptionUtilities)
37 # Sets GMX_USE_PLUGINS=ON in the parent scope if the toolchain and
38 # user selections permit the build to support plugin loading.
39 function(gmx_manage_plugin_support)
40 gmx_option_trivalue(GMX_LOAD_PLUGINS "Compile with plugin support, needed to read VMD supported file formats" AUTO)
41 mark_as_advanced(GMX_LOAD_PLUGINS)
43 # Find out if non-Windows builds can support plugins. Native Windows
44 # neither needs nor has library support.
46 # TODO Make a proper find_package for dlopen to find
47 # dlfcn.h. The CMake variable CMAKE_DL_LIBS works magically
48 # for the library, however.
49 include(gmxTestdlopen)
50 gmx_test_dlopen(HAVE_DLOPEN)
53 # Keep the status line quiet unless something relevant has
55 gmx_check_if_changed(EMIT_STATUS_MESSAGES GMX_LOAD_PLUGINS BUILD_SHARED_LIBS HAVE_DLOPEN)
57 # Whether GROMACS will really try to compile support for VMD
59 set(GMX_USE_PLUGINS OFF)
61 # Plugins are supported natively on Windows
62 if (WIN32 OR (BUILD_SHARED_LIBS AND HAVE_DLOPEN))
63 set(GMX_USE_PLUGINS ${GMX_LOAD_PLUGINS})
64 elseif(GMX_LOAD_PLUGINS)
65 # Can't support plugins for some reason. If the user required
66 # plugins, emit fatal errors. Otherwise, emit status messages
67 # for AUTO and be silent for OFF.
70 set(message "${message}dlopen() support for using dynamic plugins for VMD-supported file formats is missing. ")
72 if(NOT BUILD_SHARED_LIBS)
73 set(message "${message}GROMACS only supports plugins in a build that uses shared libraries, which can be disabled for various reasons. BUILD_SHARED_LIBS=on and a toolchain that supports dynamic linking is required. (Hint: GMX_PREFER_STATIC_LIBS and GMX_BUILD_MDRUN_ONLY can influence the default BUILD_SHARED_LIBS, so if you need plugins, reconsider those choices.) ")
75 if (GMX_LOAD_PLUGINS_FORCE)
76 message(FATAL_ERROR "${message}Cannot build with GMX_LOAD_PLUGINS=${GMX_LOAD_PLUGINS}.")
78 if (GMX_LOAD_PLUGINS_AUTO AND EMIT_STATUS_MESSAGES)
79 message(STATUS "${message}")
83 if(EMIT_STATUS_MESSAGES)
85 MESSAGE(STATUS "Using dynamic plugins (e.g VMD-supported file formats)")
87 MESSAGE(STATUS "Not using dynamic plugins (e.g VMD-supported file formats)")
90 set(GMX_USE_PLUGINS ${GMX_USE_PLUGINS} PARENT_SCOPE)
93 gmx_manage_plugin_support()
96 list(APPEND GMX_EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) # magic cross-platform pre-set variable for dlopen library
97 set(PKG_DL_LIBS "-l${CMAKE_DL_LIBS}")