3 # Looks for the OpenMM libraries at the default (/usr/local) location
4 # or custom location found in the OPENMM_ROOT_DIR environment variable.
6 # The script defines defines:
12 # OpenMM_LIBRARIES_D - debug version of libraries
16 # Author: Szilard Pall (pszilard@cbr.su.se)
18 if(OpenMM_INCLUDE_DIR AND OpenMM_LIBRARY_DIR AND OpenMM_PLUGIN_DIR)
19 set(OpenMM_FIND_QUIETLY)
22 file(TO_CMAKE_PATH "$ENV{OPENMM_ROOT_DIR}" _env_OPENMM_ROOT_DIR)
24 if(IS_DIRECTORY ${_env_OPENMM_ROOT_DIR})
25 set(OpenMM_ROOT_DIR "${_env_OPENMM_ROOT_DIR}" CACHE PATH "OpenMM installation directory" FORCE)
27 if(IS_DIRECTORY "/usr/local/openmm")
28 set(OpenMM_ROOT_DIR "/usr/local/openmm" CACHE PATH "OpenMM installation directory" FORCE)
32 find_library(OpenMM_LIBRARIES
34 PATHS "${OpenMM_ROOT_DIR}/lib"
35 CACHE STRING "OpenMM libraries")
37 find_library(OpenMM_LIBRARIES_D
39 PATHS "${OpenMM_ROOT_DIR}/lib"
40 CACHE STRING "OpenMM debug libraries")
42 if(OpenMM_LIBRARIES_D AND NOT OpenMM_LIBRARIES)
43 set(OpenMM_LIBRARIES ${OpenMM_LIBRARIES_D}
44 CACHE STRING "OpenMM libraries" FORCE)
45 message(WARNING " Only found debug versions of the OpenMM libraries!")
48 get_filename_component(OpenMM_LIBRARY_DIR
51 CACHE STRING "OpenMM library path")
53 find_path(OpenMM_INCLUDE_DIR
55 PATHS "${OpenMM_ROOT_DIR}/include" "${OpenMM_LIBRARY_DIR}/../include"
56 CACHE STRING "OpenMM include directory")
58 # if we did not manage to set the root dir at the beginning but found the
59 # libs then set the ${OpenMM_LIBRARY_DIR}/.. as root
60 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
61 if (IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/..") # just double-checking
62 get_filename_component(OpenMM_ROOT_DIR
63 "${OpenMM_LIBRARY_DIR}/.."
68 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
69 message(FATAL_ERROR "Can't find OpenMM! Either set the OPENMM_ROOT_DIR environment "
70 "variable to the path where your OpenMM installation is located or install it to the default location (/usr/local/openmm)!")
73 if(NOT IS_DIRECTORY ${OpenMM_LIBRARY_DIR})
74 message(FATAL_ERROR "Can't find OpenMM libraries. Check your OpenMM installation!")
77 # now we can be sure that we have the library dir
78 if(IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/plugins")
79 get_filename_component(OpenMM_PLUGIN_DIR
80 "${OpenMM_LIBRARY_DIR}/plugins"
82 set(OpenMM_PLUGIN_DIR ${OpenMM_PLUGIN_DIR} CACHE PATH "OpenMM plugins directory")
84 message(WARNING "Could not detect the OpenMM plugin directory at the default location (${OpenMM_LIBRARY_DIR}/plugins)."
85 "Check you OpenMM installation or manually set the OPENMM_PLUGIN_DIR environment variable!")
88 if(NOT OpenMM_INCLUDE_DIR)
89 message(FATAL_ERROR "Can't find OpenMM includes. Check your OpenMM installation!")
92 set(OpenMM_ROOT_DIR ${OpenMM_ROOT_DIR} CACHE PATH "OpenMM installation directory")
94 include(FindPackageHandleStandardArgs)
95 find_package_handle_standard_args(OpenMM DEFAULT_MSG
101 mark_as_advanced(OpenMM_INCLUDE_DIR