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 |
include (MacroEnsureVersion) |
13 |
|
14 |
if (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET) |
15 |
# in cache already |
16 |
set(OPENBABEL2_FOUND TRUE) |
17 |
|
18 |
else (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL2_VERSION_MET) |
19 |
if(EMBED_OPENBABEL) |
20 |
# 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) |
33 |
|
34 |
# Use the newer PkgConfig stuff |
35 |
find_package(PkgConfig REQUIRED) |
36 |
pkg_check_modules(OPENBABEL2 openbabel-2.0>=2.2.2) |
37 |
|
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") |
43 |
|
44 |
else(NOT WIN32) |
45 |
set(OPENBABEL2_VERSION_MET TRUE) |
46 |
endif(NOT WIN32) |
47 |
|
48 |
if(OPENBABEL2_VERSION_MET) |
49 |
|
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) |
63 |
|
64 |
find_library(OPENBABEL2_LIBRARIES NAMES openbabel openbabel-2 |
65 |
PATHS |
66 |
${_obLinkDir} |
67 |
${GNUWIN32_DIR}/lib |
68 |
$ENV{OPENBABEL2_LIBRARIES} |
69 |
) |
70 |
endif(OPENBABEL2_VERSION_MET) |
71 |
endif(EMBED_OPENBABEL) |
72 |
|
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) |
76 |
|
77 |
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) |
86 |
|
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) |