1 # This file is part of Gromacs Copyright (c) 1991-2008
2 # David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # To help us fund GROMACS development, we humbly ask that you cite
10 # the research papers on the package. Check out http://www.gromacs.org
13 # The module defines the following variables:
14 # VMD_EXECUTABLE - path to vmd command
15 # GMX_VMD_PLUGIN_PATH - path to vmd plugins
17 message(STATUS "Checking for suitable VMD version")
18 find_program(VMD_EXECUTABLE NAMES vmd PATH_SUFFIXES bin
21 #set search path in increasing priority:
22 # default path, vmd binary path, enviroment variable
23 set(VMD_PATHS "/usr/local/lib/vmd/plugins/*/molfile/")
25 file(STRINGS "${VMD_EXECUTABLE}" VMDDIR REGEX "^defaultvmddir=.*$")
26 string(REGEX REPLACE "(^.*=\"?|\"$)" "" VMDDIR "${VMDDIR}")
27 list(INSERT VMD_PATHS 0 "${VMDDIR}/plugins/*/molfile/")
29 if(NOT "$ENV{VMDDIR}" STREQUAL "")
30 list(INSERT VMD_PATHS 0 "$ENV{VMDDIR}/plugins/*/molfile/")
33 #xyz is just an example. Any other molfile plugin could be used.
34 #But some require extra link flags. VMD uses ".so" even on Windows.
35 find_library(VMDXYZPLUGIN NAME "xyzplugin.so"
39 try_run(TESTVMD TESTVMD_COMPILED ${CMAKE_BINARY_DIR}
40 "${CMAKE_SOURCE_DIR}/cmake/TestVMD.c"
41 CMAKE_FLAGS "-DLINK_LIBRARIES=${CMAKE_DL_LIBS}"
42 "-DINCLUDE_DIRECTORIES=${CMAKE_SOURCE_DIR}/src/gmxlib"
43 COMPILE_DEFINITIONS "-DGMX_USE_PLUGINS"
44 RUN_OUTPUT_VARIABLE TESTVMD_OUTPUT ARGS ${VMDXYZPLUGIN})
47 if(NOT TESTVMD EQUAL 0)
49 message(STATUS "VMD plugins not found. Path to VMD can be set with VMDDIR.")
50 elseif(NOT TESTVMD_COMPILED)
51 message(STATUS "Could not compile VMD version check")
52 elseif(TESTVMD EQUAL 1)
53 message(STATUS "Could not load VMD plugin ${VMDXYZPLUGIN}: ${TESTVMD_OUTPUT}")
54 elseif(TESTVMD EQUAL 5)
55 message(STATUS "VMD plugin ${VMDXYZPLUGIN} too old. VMD 1.8.6 required.")
57 message(STATUS "Could not identify VMD version of ${VMDXYZPLUGIN}. Error: ${TESTVMD}")
59 # This permits GROMACS to avoid hard-coding a fall-back path.
60 # Fall-back is useful in case VMD is installed later.
61 set(GMX_VMD_PLUGIN_PATH "/usr/local/lib/vmd/plugins/*/molfile"
62 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
64 get_filename_component(VMD_PLUGIN_PATH ${VMDXYZPLUGIN} PATH)
65 message(STATUS "VMD version of ${VMD_PLUGIN_PATH} is suitable")
66 set(GMX_VMD_PLUGIN_PATH ${VMD_PLUGIN_PATH}
67 CACHE PATH "Path to VMD plugins for molfile I/O" FORCE)
69 mark_as_advanced(GMX_VMD_PLUGIN_PATH)
70 #Nothing is rerun unless GMX_VMD_PLUGIN_PATH is set to NO. Clean-up all.
71 unset(VMDXYZPLUGIN CACHE)
72 unset(VMD_EXECUTABLE CACHE)
74 unset(TESTVMD_COMPILED CACHE)
76 unset(VMD_PLUGIN_PATH)