2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012,2013, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # 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 # This file is part of Gromacs Copyright (c) 1991-2008
36 # David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
38 # The module defines the following variables:
39 # VMD_EXECUTABLE - path to vmd command
40 # GMX_VMD_PLUGIN_PATH - path to vmd plugins
42 message(STATUS "Checking for suitable VMD version")
43 find_program(VMD_EXECUTABLE NAMES vmd PATH_SUFFIXES bin
46 #set search path in increasing priority:
47 # default path, vmd binary path, enviroment variable
48 set(VMD_PATHS "/usr/local/lib/vmd/plugins/*/molfile/")
50 file(STRINGS "${VMD_EXECUTABLE}" VMDDIR REGEX "^defaultvmddir=.*$")
51 string(REGEX REPLACE "(^.*=\"?|\"$)" "" VMDDIR "${VMDDIR}")
52 list(INSERT VMD_PATHS 0 "${VMDDIR}/plugins/*/molfile/")
54 if(NOT "$ENV{VMDDIR}" STREQUAL "")
55 list(INSERT VMD_PATHS 0 "$ENV{VMDDIR}/plugins/*/molfile/")
58 #xyz is just an example. Any other molfile plugin could be used.
59 #But some require extra link flags. VMD uses ".so" even on Windows.
60 find_library(VMDXYZPLUGIN NAME "xyzplugin.so"
64 try_run(TESTVMD TESTVMD_COMPILED ${CMAKE_BINARY_DIR}
65 "${CMAKE_SOURCE_DIR}/cmake/TestVMD.c"
66 CMAKE_FLAGS "-DLINK_LIBRARIES=${CMAKE_DL_LIBS}"
67 "-DINCLUDE_DIRECTORIES=${CMAKE_SOURCE_DIR}/src/gmxlib"
68 COMPILE_DEFINITIONS "-DGMX_USE_PLUGINS"
69 RUN_OUTPUT_VARIABLE TESTVMD_OUTPUT ARGS ${VMDXYZPLUGIN})
72 if(NOT TESTVMD EQUAL 0)
74 message(STATUS "VMD plugins not found. Path to VMD can be set with VMDDIR.")
75 elseif(NOT TESTVMD_COMPILED)
76 message(STATUS "Could not compile VMD version check")
77 elseif(TESTVMD EQUAL 1)
78 message(STATUS "Could not load VMD plugin ${VMDXYZPLUGIN}: ${TESTVMD_OUTPUT}")
79 elseif(TESTVMD EQUAL 5)
80 message(STATUS "VMD plugin ${VMDXYZPLUGIN} too old. VMD 1.8.6 required.")
82 message(STATUS "Could not identify VMD version of ${VMDXYZPLUGIN}. Error: ${TESTVMD}")
84 # This permits GROMACS to avoid hard-coding a fall-back path.
85 # Fall-back is useful in case VMD is installed later.
86 set(GMX_VMD_PLUGIN_PATH "/usr/local/lib/vmd/plugins/*/molfile"
87 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
89 get_filename_component(VMD_PLUGIN_PATH ${VMDXYZPLUGIN} PATH)
90 message(STATUS "VMD version of ${VMD_PLUGIN_PATH} is suitable")
91 set(GMX_VMD_PLUGIN_PATH ${VMD_PLUGIN_PATH}
92 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
94 mark_as_advanced(GMX_VMD_PLUGIN_PATH)
95 #Nothing is rerun unless GMX_VMD_PLUGIN_PATH is set to NO. Clean-up all.
96 unset(VMDXYZPLUGIN CACHE)
97 unset(VMD_EXECUTABLE CACHE)
99 unset(TESTVMD_COMPILED CACHE)
101 unset(VMD_PLUGIN_PATH)