updated FindCUDA to version from cmake 2.8.1 for CUDA 2.3 support
[gromacs/rigid-bodies.git] / cmake / FindOpenMM.cmake
blobc3c08a8645b0eba2fd00346fd14cf342fd4893eb
1 # Find OpenMM library 
3 # Defines: 
4 #  OpenMM_FOUND     
5 #  OpenMM_ROOT_DIR
6 #  OpenMM_INCLUDE_DIR
7 #  OpenMM_LIBRARY_DIR
8 #  OpenMM_LIBRARIES
9 #  OpenMM_PLUGIN_DIR
12 # include(LibFindMacros) TODO get this: http://zi.fi/cmake/Modules/LibFindMacros.cmake
14 if(OpenMM_INCLUDE_DIR AND OpenMM_LIBRARY_DIR AND OpenMM_PLUGIN_DIR)
15     set(OpenMM_FIND_QUIETLY)
16 endif()
18 if(IS_DIRECTORY "$ENV{OPENMM_ROOT_DIR}")
19     set(OpenMM_ROOT_DIR $ENV{OPENMM_ROOT_DIR} CACHE PATH "OpenMM installation directory" FORCE)
20 else()
21     if(IS_DIRECTORY "/usr/local/openmm")
22         set(OpenMM_ROOT_DIR "/usr/local/openmm" CACHE PATH "OpenMM installation directory" FORCE)
23     endif()
24 endif()
26 find_library(OpenMM_LIBRARIES
27     NAMES OpenMM
28     PATHS "${OpenMM_ROOT_DIR}/lib")
30 get_filename_component(OpenMM_LIBRARY_DIR 
31     ${OpenMM_LIBRARIES} 
32     PATH
33     CACHE STRING "OpenMM library path")
35 find_path(OpenMM_INCLUDE_DIR 
36     NAMES OpenMM.h 
37     PATHS "${OpenMM_ROOT_DIR}/include" "${OpenMM_LIBRARY_DIR}/../include"
38     CACHE STRING "OpenMM include directory")    
40 # if we did not manage to set the root dir at the beginning but found the 
41 # libs then set the ${OpenMM_LIBRARY_DIR}/.. as root
42 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
43     if (IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/..") # just double-checking
44         get_filename_component(OpenMM_ROOT_DIR 
45             "${OpenMM_LIBRARY_DIR}/.." 
46             ABSOLUTE
47             CACHE PATH "OpenMM installation directory")
48     endif()
49 endif()
51 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
52     message(FATAL_ERROR "Can't find OpenMM! Either set the OPENMM_ROOT_DIR environment " 
53     "variable to the path where your OpenMM installation is located or install it to the default location (/usr/local/openmm)!")
54 endif()
56 if(NOT OpenMM_LIBRARY_DIR)
57     message(FATAL_ERROR "Can't find OpenMM libraries. Check your OpenMM installation!")
58 endif()
60 # now we can be sure that we have the library dir
61 if(IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/plugins")
62     get_filename_component(OpenMM_PLUGIN_DIR
63         "${OpenMM_LIBRARY_DIR}/plugins"
64         ABSOLUTE
65         CACHE PATH "OpenMM plugins directory")
66 else()
67     message(WARNING "Could not detect the OpenMM plugin directory at the default location (${OpenMM_LIBRARY_DIR}/plugins)."
68             "Check you OpenMM installation or manually set the OPENMM_PLUGIN_DIR environment variable!")
69 endif()
71 if(NOT OpenMM_INCLUDE_DIR)
72     message(FATAL_ERROR "Can't find OpenMM includes. Check your OpenMM installation!")
73 endif()
75 include (FindPackageHandleStandardArgs)
76 find_package_handle_standard_args(OpenMM DEFAULT_MSG 
77                                     OpenMM_ROOT_DIR
78                                     OpenMM_LIBRARIES 
79                                     OpenMM_LIBRARY_DIR 
80                                     OpenMM_INCLUDE_DIR
81                                     OpenMM_PLUGIN_DIR)