ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/cmake/modules/FindOpenBabel2.cmake
(Generate patch)

Comparing branches/development/cmake/modules/FindOpenBabel2.cmake (file contents):
Revision 1466 by chuckv, Fri Jul 9 23:13:29 2010 UTC vs.
Revision 1700 by gezelter, Mon Mar 26 15:27:16 2012 UTC

# Line 4 | Line 4
4   #  OPENBABEL2_FOUND - system has OpenBabel2
5   #  OPENBABEL2_INCLUDE_DIR - the OpenBabel2 include directory
6   #  OPENBABEL2_LIBRARIES - Link these to use OpenBabel2
7 + #
8 + # A simplified version of FindOpenBabel2.cmake which doesn't rely
9 + # on PkgConfig and doesn't search for the executable.
10 + #
11   # Copyright (c) 2006, 2007 Carsten Niehaus, <cniehaus@gmx.de>
12   # Copyright (C) 2008 Marcus D. Hanwell <marcus@cryos.org>
13 + # Copyright (C) 2012 J. Daniel Gezelter <gezelter@openscience.org>
14   # Redistribution and use is allowed according to the terms of the BSD license.
15   # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
16  
12 include (MacroEnsureVersion)
17  
14 if (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
15  # in cache already
16  set(OPENBABEL2_FOUND TRUE)
18  
19 < else (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
20 <  if(EMBED_OPENBABEL)
21 <    # Building a super-package, rely on the embedded paths
21 <    set(OPENBABEL2_VERSION_MET TRUE)
22 <    set(OPENBABEL2_INCLUDE_DIR ${super_SOURCE_DIR}/openbabel/include ${super_BINARY_DIR}/openbabel/include)
23 <    # This is a kludge -- need to ask Marcus how to handle it better
24 <    find_library(OPENBABEL2_LIBRARIES NAMES openbabel openbabel-2
25 <      PATHS
26 <      ${_obLinkDir}
27 <      ${GNUWIN32_DIR}/lib
28 <      $ENV{OPENBABEL2_LIBRARIES}
29 <    )
30 <  else(EMBED_OPENBABEL)
31 <  # Typical case -- find an installed OpenBabel
32 <  if(NOT WIN32)
19 > FIND_PATH(OPENBABEL2_INCLUDE_DIR openbabel-2.0/openbabel/obconversion.h
20 >          HINTS "${_obDir}" "${GNUWIN32_DIR}" "${OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_INCLUDE_DIR}"
21 >          PATH_SUFFIXES include )
22  
23 <    # Use the newer PkgConfig stuff
24 <    find_package(PkgConfig REQUIRED)
25 <    pkg_check_modules(OPENBABEL2 openbabel-2.0>=2.2.2)
23 > if(OPENBABEL2_INCLUDE_DIR)
24 >    set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIR}/openbabel-2.0)
25 > endif(OPENBABEL2_INCLUDE_DIR)
26  
38    # Maintain backwards compatibility with previous version of module
39    if(OPENBABEL2_FOUND STREQUAL "1")
40      set(OPENBABEL2_VERSION_MET TRUE)
41      set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIRS})
42    endif(OPENBABEL2_FOUND STREQUAL "1")
27  
28 <  else(NOT WIN32)
29 <    set(OPENBABEL2_VERSION_MET TRUE)
30 <  endif(NOT WIN32)
28 > FIND_LIBRARY(OPENBABEL2_LIBRARY NAMES openbabel openbabel2
29 >               HINTS "${_obDir}" "${GNUWIN32_DIR}" "${OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_LIBRARIES}"
30 >               PATH_SUFFIXES project build bin lib lib64 )
31  
32 <  if(OPENBABEL2_VERSION_MET)
32 > # handle the QUIETLY and REQUIRED arguments and set OPENBABEL2_FOUND to TRUE if
33 > # all listed variables are TRUE
34 > INCLUDE(FindPackageHandleStandardArgs)
35 > FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenBabel2 DEFAULT_MSG OPENBABEL2_LIBRARY OPENBABEL2_INCLUDE_DIR)
36  
50    if(WIN32)
51      if(NOT OPENBABEL2_INCLUDE_DIR)
52        find_path(OPENBABEL2_INCLUDE_DIR openbabel-2.0/openbabel/obconversion.h
53          PATHS
54          ${_obIncDir}
55          ${GNUWIN32_DIR}/include
56          $ENV{OPENBABEL2_INCLUDE_DIR}
57        )
58        if(OPENBABEL2_INCLUDE_DIR)
59          set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIR}/openbabel-2.0)
60        endif(OPENBABEL2_INCLUDE_DIR)
61      endif(NOT OPENBABEL2_INCLUDE_DIR)
62    endif(WIN32)
37  
38 <    find_library(OPENBABEL2_LIBRARIES NAMES openbabel openbabel-2
39 <      PATHS
40 <      ${_obLinkDir}
41 <      ${GNUWIN32_DIR}/lib
68 <      $ENV{OPENBABEL2_LIBRARIES}
69 <    )
70 <  endif(OPENBABEL2_VERSION_MET)
71 <  endif(EMBED_OPENBABEL)
38 > if(OPENBABEL2_FOUND)
39 >  set( OPENBABEL2_LIBRARIES ${OPENBABEL2_LIBRARY} )
40 >  set( OPENBABEL2_INCLUDE_DIRS ${OPENBABEL2_INCLUDE_DIR} )
41 > endif()
42  
73  if(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
74    set(OPENBABEL2_FOUND TRUE)
75  endif(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
43  
44 <  if (OPENBABEL2_FOUND)
78 <    if (NOT OpenBabel2_FIND_QUIETLY)
79 <      message(STATUS "Found OpenBabel 2.2 or later: ${OPENBABEL2_LIBRARIES}")
80 <    endif (NOT OpenBabel2_FIND_QUIETLY)
81 <  else (OPENBABEL2_FOUND)
82 <    if (OpenBabel2_FIND_REQUIRED)
83 <      message(FATAL_ERROR "Could NOT find OpenBabel 2.2 or later ")
84 <    endif (OpenBabel2_FIND_REQUIRED)
85 <  endif (OPENBABEL2_FOUND)
44 > MARK_AS_ADVANCED(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARY)
45  
87  mark_as_advanced(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARIES)
88
89 endif (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
90
91 # Search for Open Babel2 executable
92 if(OPENBABEL2_EXECUTABLE)
93
94  # in cache already
95  set(OPENBABEL2_EXECUTABLE_FOUND TRUE)
96
97 else(OPENBABEL2_EXECUTABLE)
98  find_program(OPENBABEL2_EXECUTABLE NAMES babel
99    PATHS
100    [HKEY_CURRENT_USER\\SOFTWARE\\OpenBabel\ 2.2.2]
101    $ENV{OPENBABEL2_EXECUTABLE}
102  )
103
104  if(OPENBABEL2_EXECUTABLE)
105    set(OPENBABEL2_EXECUTABLE_FOUND TRUE)
106  endif(OPENBABEL2_EXECUTABLE)
107
108  if(OPENBABEL2_EXECUTABLE_FOUND)
109    message(STATUS "Found OpenBabel2 executable: ${OPENBABEL2_EXECUTABLE}")
110  endif(OPENBABEL2_EXECUTABLE_FOUND)
111
112 endif(OPENBABEL2_EXECUTABLE)
113
114 # Test if we are using trunk
115 if(NOT OPENBABEL_IS_NEWER_THAN_2_2_99)
116  macro_ensure_version("2.2.99" "${OPENBABEL2_VERSION}" OPENBABEL_IS_NEWER_THAN_2_2_99)
117 endif(NOT OPENBABEL_IS_NEWER_THAN_2_2_99)
118 if (OPENBABEL_IS_NEWER_THAN_2_2_99)
119   add_definitions(-DOPENBABEL_IS_NEWER_THAN_2_2_99)
120 endif(OPENBABEL_IS_NEWER_THAN_2_2_99)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines