minor updates to FindGit and FindOpenMM
authorSzilard Pall <pszilard@cbr.su.se>
Fri, 7 May 2010 12:30:59 +0000 (14:30 +0200)
committerSzilard Pall <pszilard@cbr.su.se>
Fri, 7 May 2010 12:30:59 +0000 (14:30 +0200)
cmake/FindGit.cmake
cmake/FindOpenMM.cmake

index 3d553ecc24e0a9221b510a6761db171384693f80..6f3631117d36a7327e289ae0ca4491aecba35272 100644 (file)
@@ -6,7 +6,7 @@
 # Git_VERSION       - git version
 # Git_FOUND         - tru if git was found, false otherwise
 #
-# Szilard Pall (pszilard@cbr.su.se)
+# Author: Szilard Pall (pszilard@cbr.su.se)
 
 if(Git_EXECUTABLE AND Git_VERSION)
     set(Git_FIND_QUIETLY TRUE)
@@ -14,7 +14,8 @@ endif()
 
 # search for git binary
 find_program(Git_EXECUTABLE git
-    DOC "Git version control tool")
+    PATHS ENV PATH
+    CACHE DOC "Git version control tool")
 
 if(NOT Git_EXECUTABLE)
     set(_err_msg "Git executable not found")
index c3c08a8645b0eba2fd00346fd14cf342fd4893eb..5094d1bd942e86ad6f346b19caaccc89ff5e5383 100644 (file)
@@ -1,22 +1,28 @@
-# Find OpenMM library 
+# Find OpenMM library.
 #
-# Defines: 
+# Looks for the OpenMM libraries at the default (/usr/local) location 
+# or custom location found in the OPENMM_ROOT_DIR environment variable. 
+#
+# The script defines defines: 
 #  OpenMM_FOUND     
 #  OpenMM_ROOT_DIR
 #  OpenMM_INCLUDE_DIR
 #  OpenMM_LIBRARY_DIR
-#  OpenMM_LIBRARIES
+#  OpenMM_LIBRARIES      
+#  OpenMM_LIBRARIES_D   - debug version of libraries 
 #  OpenMM_PLUGIN_DIR
 #
 
-# include(LibFindMacros) TODO get this: http://zi.fi/cmake/Modules/LibFindMacros.cmake
+# Author: Szilard Pall (pszilard@cbr.su.se)
 
 if(OpenMM_INCLUDE_DIR AND OpenMM_LIBRARY_DIR AND OpenMM_PLUGIN_DIR)
     set(OpenMM_FIND_QUIETLY)
 endif()
 
-if(IS_DIRECTORY "$ENV{OPENMM_ROOT_DIR}")
-    set(OpenMM_ROOT_DIR $ENV{OPENMM_ROOT_DIR} CACHE PATH "OpenMM installation directory" FORCE)
+file(TO_CMAKE_PATH "$ENV{OPENMM_ROOT_DIR}" _env_OPENMM_ROOT_DIR)
+
+if(IS_DIRECTORY ${_env_OPENMM_ROOT_DIR})
+    set(OpenMM_ROOT_DIR "${_env_OPENMM_ROOT_DIR}" CACHE PATH "OpenMM installation directory" FORCE)
 else()
     if(IS_DIRECTORY "/usr/local/openmm")
         set(OpenMM_ROOT_DIR "/usr/local/openmm" CACHE PATH "OpenMM installation directory" FORCE)
@@ -25,7 +31,19 @@ endif()
 
 find_library(OpenMM_LIBRARIES
     NAMES OpenMM
-    PATHS "${OpenMM_ROOT_DIR}/lib")
+    PATHS "${OpenMM_ROOT_DIR}/lib"
+    CACHE STRING "OpenMM libraries")
+
+find_library(OpenMM_LIBRARIES_D
+    NAMES OpenMM_d
+    PATHS "${OpenMM_ROOT_DIR}/lib"
+    CACHE STRING "OpenMM debug libraries")
+
+if(OpenMM_LIBRARIES_D AND NOT OpenMM_LIBRARIES)
+    set(OpenMM_LIBRARIES ${OpenMM_LIBRARIES_D}
+        CACHE STRING "OpenMM libraries" FORCE)
+    message(WARNING " Only found debug versions of the OpenMM libraries!")
+endif()
 
 get_filename_component(OpenMM_LIBRARY_DIR 
     ${OpenMM_LIBRARIES} 
@@ -43,9 +61,8 @@ if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
     if (IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/..") # just double-checking
         get_filename_component(OpenMM_ROOT_DIR 
             "${OpenMM_LIBRARY_DIR}/.." 
-            ABSOLUTE
-            CACHE PATH "OpenMM installation directory")
-    endif()
+            ABSOLUTE)
+    endif()   
 endif()
 
 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
@@ -53,7 +70,7 @@ if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
     "variable to the path where your OpenMM installation is located or install it to the default location (/usr/local/openmm)!")
 endif()
 
-if(NOT OpenMM_LIBRARY_DIR)
+if(NOT IS_DIRECTORY ${OpenMM_LIBRARY_DIR})
     message(FATAL_ERROR "Can't find OpenMM libraries. Check your OpenMM installation!")
 endif()
 
@@ -61,8 +78,8 @@ endif()
 if(IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/plugins")
     get_filename_component(OpenMM_PLUGIN_DIR
         "${OpenMM_LIBRARY_DIR}/plugins"
-        ABSOLUTE
-        CACHE PATH "OpenMM plugins directory")
+        ABSOLUTE)
+    set(OpenMM_PLUGIN_DIR ${OpenMM_PLUGIN_DIR} CACHE PATH "OpenMM plugins directory")
 else()
     message(WARNING "Could not detect the OpenMM plugin directory at the default location (${OpenMM_LIBRARY_DIR}/plugins)."
             "Check you OpenMM installation or manually set the OPENMM_PLUGIN_DIR environment variable!")
@@ -72,10 +89,16 @@ if(NOT OpenMM_INCLUDE_DIR)
     message(FATAL_ERROR "Can't find OpenMM includes. Check your OpenMM installation!")
 endif()
 
-include (FindPackageHandleStandardArgs)
+set(OpenMM_ROOT_DIR ${OpenMM_ROOT_DIR} CACHE PATH "OpenMM installation directory")
+
+include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(OpenMM DEFAULT_MSG 
                                     OpenMM_ROOT_DIR
                                     OpenMM_LIBRARIES 
                                     OpenMM_LIBRARY_DIR 
-                                    OpenMM_INCLUDE_DIR
-                                    OpenMM_PLUGIN_DIR)
+                                    OpenMM_INCLUDE_DIR)
+
+mark_as_advanced(OpenMM_INCLUDE_DIR
+    OpenMM_LIBRARIES
+    OpenMM_LIBRARIES_D
+    OpenMM_LIBRARY_DIR)