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 1694 by gezelter, Thu Mar 15 23:51:48 2012 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 if (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
13  # in cache already
14  set(OPENBABEL2_FOUND TRUE)
17  
16 else (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
17  if(NOT WIN32)
18  
19 <    # Use the newer PkgConfig stuff
20 <    find_package(PkgConfig REQUIRED)
21 <    pkg_check_modules(OPENBABEL2 openbabel-2.0>=2.2.0)
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 <    # Maintain backwards compatibility with previous version of module
24 <    if(OPENBABEL2_FOUND STREQUAL "1")
25 <      set(OPENBABEL2_VERSION_MET TRUE)
26 <      set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIRS})
27 <    endif(OPENBABEL2_FOUND STREQUAL "1")
23 > if(OPENBABEL2_INCLUDE_DIR)
24 >    set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIR}/openbabel-2.0)
25 > endif(OPENBABEL2_INCLUDE_DIR)
26  
29  else(NOT WIN32)
30    set(OPENBABEL2_VERSION_MET TRUE)
31  endif(NOT WIN32)
27  
28 <  if(OPENBABEL2_VERSION_MET)
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 <   # find_path(OPENBABEL2_INCLUDE_DIR openbabel/obconversion.h
33 <   #   PATHS
34 <   #   ${_obIncDir}
35 <   #   ${GNUWIN32_DIR}/include
39 <   #   $ENV{OPENBABEL2_INCLUDE_DIR}
40 <   # )
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  
42    if(WIN32)
43      if(NOT OPENBABEL2_INCLUDE_DIR)
44        find_path(OPENBABEL2_INCLUDE_DIR openbabel-2.0/openbabel/obconversion.h
45          PATHS
46          ${_obIncDir}
47          ${GNUWIN32_DIR}/include
48          $ENV{OPENBABEL2_INCLUDE_DIR}
49        )
50        if(OPENBABEL2_INCLUDE_DIR)
51          set(OPENBABEL2_INCLUDE_DIR ${OPENBABEL2_INCLUDE_DIR}/openbabel-2.0)
52        endif(OPENBABEL2_INCLUDE_DIR)
53      endif(NOT OPENBABEL2_INCLUDE_DIR)
54    endif(WIN32)
37  
38 <  find_library(OPENBABEL2_LIBRARIES
39 <               NAMES openbabel openbabel-2
40 <               HINTS "${_obLinkDir}" "${GNUWIN32_DIR}" "${OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_LIBRARIES}"
41 <               PATH_SUFFIXES project build bin lib lib64)
38 > if(OPENBABEL2_FOUND)
39 >  set( OPENBABEL2_LIBRARIES ${OPENBABEL2_LIBRARY} )
40 >  set( OPENBABEL2_INCLUDE_DIRS ${OPENBABEL2_INCLUDE_DIR} )
41 > endif()
42  
61  endif(OPENBABEL2_VERSION_MET)
43  
44 <  if(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
64 <    set(OPENBABEL2_FOUND TRUE)
65 <  endif(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
44 > MARK_AS_ADVANCED(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARY)
45  
67  if (OPENBABEL2_FOUND)
68    if (NOT OpenBabel2_FIND_QUIETLY)
69      message(STATUS "Found OpenBabel 2.2 or later: ${OPENBABEL2_LIBRARIES}")
70    endif (NOT OpenBabel2_FIND_QUIETLY)
71  else (OPENBABEL2_FOUND)
72    if (OpenBabel2_FIND_REQUIRED)
73      message(FATAL_ERROR "Could NOT find OpenBabel 2.2 or later ")
74    endif (OpenBabel2_FIND_REQUIRED)
75  endif (OPENBABEL2_FOUND)
76
77  mark_as_advanced(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARIES)
78
79 endif (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
80
81 # Search for Open Babel2 executable
82 if(OPENBABEL2_EXECUTABLE)
83
84  # in cache already
85  set(OPENBABEL2_EXECUTABLE_FOUND TRUE)
86
87 else(OPENBABEL2_EXECUTABLE)
88  find_program(OPENBABEL2_EXECUTABLE NAMES babel
89    PATHS
90    [HKEY_CURRENT_USER\\SOFTWARE\\OpenBabel\ 2.2.0]
91    $ENV{OPENBABEL2_EXECUTABLE}
92  )
93
94  if(OPENBABEL2_EXECUTABLE)
95    set(OPENBABEL2_EXECUTABLE_FOUND TRUE)
96  endif(OPENBABEL2_EXECUTABLE)
97
98  if(OPENBABEL2_EXECUTABLE_FOUND)
99    message(STATUS "Found OpenBabel2 executable: ${OPENBABEL2_EXECUTABLE}")
100  endif(OPENBABEL2_EXECUTABLE_FOUND)
101
102 endif(OPENBABEL2_EXECUTABLE)
103

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines