ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/cmake/modules/FindOpenBabel2.cmake
Revision: 1694
Committed: Thu Mar 15 23:51:48 2012 UTC (13 years, 1 month ago) by gezelter
File size: 3428 byte(s)
Log Message:
Doing some work to simplify cmake build process

File Contents

# Content
1 # - Try to find OpenBabel2
2 # Once done this will define
3 #
4 # OPENBABEL2_FOUND - system has OpenBabel2
5 # OPENBABEL2_INCLUDE_DIR - the OpenBabel2 include directory
6 # OPENBABEL2_LIBRARIES - Link these to use OpenBabel2
7 # Copyright (c) 2006, 2007 Carsten Niehaus, <cniehaus@gmx.de>
8 # Copyright (C) 2008 Marcus D. Hanwell <marcus@cryos.org>
9 # Redistribution and use is allowed according to the terms of the BSD license.
10 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
11
12 if (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET)
13 # in cache already
14 set(OPENBABEL2_FOUND TRUE)
15
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)
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")
28
29 else(NOT WIN32)
30 set(OPENBABEL2_VERSION_MET TRUE)
31 endif(NOT WIN32)
32
33 if(OPENBABEL2_VERSION_MET)
34
35 # find_path(OPENBABEL2_INCLUDE_DIR openbabel/obconversion.h
36 # PATHS
37 # ${_obIncDir}
38 # ${GNUWIN32_DIR}/include
39 # $ENV{OPENBABEL2_INCLUDE_DIR}
40 # )
41
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)
55
56 find_library(OPENBABEL2_LIBRARIES
57 NAMES openbabel openbabel-2
58 HINTS "${_obLinkDir}" "${GNUWIN32_DIR}" "${OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_ROOT}" "$ENV{OPENBABEL2_LIBRARIES}"
59 PATH_SUFFIXES project build bin lib lib64)
60
61 endif(OPENBABEL2_VERSION_MET)
62
63 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)
66
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