2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012, 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 # This program is free software; you can redistribute it and/or
39 # modify it under the terms of the GNU General Public License
40 # as published by the Free Software Foundation; either version 2
41 # of the License, or (at your option) any later version.
43 # To help us fund GROMACS development, we humbly ask that you cite
44 # the research papers on the package. Check out http://www.gromacs.org
47 # The module defines the following variables:
48 # VMD_EXECUTABLE - path to vmd command
49 # GMX_VMD_PLUGIN_PATH - path to vmd plugins
51 message(STATUS "Checking for suitable VMD version")
52 find_program(VMD_EXECUTABLE NAMES vmd PATH_SUFFIXES bin
55 #set search path in increasing priority:
56 # default path, vmd binary path, enviroment variable
57 set(VMD_PATHS "/usr/local/lib/vmd/plugins/*/molfile/")
59 file(STRINGS "${VMD_EXECUTABLE}" VMDDIR REGEX "^defaultvmddir=.*$")
60 string(REGEX REPLACE "(^.*=\"?|\"$)" "" VMDDIR "${VMDDIR}")
61 list(INSERT VMD_PATHS 0 "${VMDDIR}/plugins/*/molfile/")
63 if(NOT "$ENV{VMDDIR}" STREQUAL "")
64 list(INSERT VMD_PATHS 0 "$ENV{VMDDIR}/plugins/*/molfile/")
67 #xyz is just an example. Any other molfile plugin could be used.
68 #But some require extra link flags. VMD uses ".so" even on Windows.
69 find_library(VMDXYZPLUGIN NAME "xyzplugin.so"
73 try_run(TESTVMD TESTVMD_COMPILED ${CMAKE_BINARY_DIR}
74 "${CMAKE_SOURCE_DIR}/cmake/TestVMD.c"
75 CMAKE_FLAGS "-DLINK_LIBRARIES=${CMAKE_DL_LIBS}"
76 "-DINCLUDE_DIRECTORIES=${CMAKE_SOURCE_DIR}/src/gmxlib"
77 COMPILE_DEFINITIONS "-DGMX_USE_PLUGINS"
78 RUN_OUTPUT_VARIABLE TESTVMD_OUTPUT ARGS ${VMDXYZPLUGIN})
81 if(NOT TESTVMD EQUAL 0)
83 message(STATUS "VMD plugins not found. Path to VMD can be set with VMDDIR.")
84 elseif(NOT TESTVMD_COMPILED)
85 message(STATUS "Could not compile VMD version check")
86 elseif(TESTVMD EQUAL 1)
87 message(STATUS "Could not load VMD plugin ${VMDXYZPLUGIN}: ${TESTVMD_OUTPUT}")
88 elseif(TESTVMD EQUAL 5)
89 message(STATUS "VMD plugin ${VMDXYZPLUGIN} too old. VMD 1.8.6 required.")
91 message(STATUS "Could not identify VMD version of ${VMDXYZPLUGIN}. Error: ${TESTVMD}")
93 # This permits GROMACS to avoid hard-coding a fall-back path.
94 # Fall-back is useful in case VMD is installed later.
95 set(GMX_VMD_PLUGIN_PATH "/usr/local/lib/vmd/plugins/*/molfile"
96 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
98 get_filename_component(VMD_PLUGIN_PATH ${VMDXYZPLUGIN} PATH)
99 message(STATUS "VMD version of ${VMD_PLUGIN_PATH} is suitable")
100 set(GMX_VMD_PLUGIN_PATH ${VMD_PLUGIN_PATH}
101 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
103 mark_as_advanced(GMX_VMD_PLUGIN_PATH)
104 #Nothing is rerun unless GMX_VMD_PLUGIN_PATH is set to NO. Clean-up all.
105 unset(VMDXYZPLUGIN CACHE)
106 unset(VMD_EXECUTABLE CACHE)
108 unset(TESTVMD_COMPILED CACHE)
110 unset(VMD_PLUGIN_PATH)