-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindMongoC.cmake
115 lines (107 loc) · 3.47 KB
/
FindMongoC.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# This module accepts the following environment variables:
#
# MONGOC_DIR, MONGOC_ROOT, or MONGOC_ROOT_DIR - Specify the location of MONGOC
#
# Read-Only variables:
# MONGOC_FOUND - system has the MONGOC library
# MONGOC_INCLUDE_DIR - the MONGOC include directory
# MONGOC_LIBRARIES - The libraries needed to use MONGOC
# MONGOC_DLLS - The dynamic libraries needed to run MONGOC program on Windows
# MONGOC_VERSION - This is set to $major.$minor.$revision$path (eg. 0.4.1)
if (UNIX)
find_package(PkgConfig QUIET)
pkg_check_modules(_MONGOC QUIET libmongoc-1.0)
endif ()
find_path(MONGOC_INCLUDE_DIR
NAMES
libmongoc-1.0/mongoc.h
HINTS
CMAKE_PREFIX_PATH
ENV MONGOC_DIR
ENV MONGOC_ROOT
ENV MONGOC_ROOT_DIR
PATH_SUFFIXES
include
)
IF(NOT ${MONGOC_INCLUDE_DIR} MATCHES "libmongoc-1.0" AND NOT ${MONGOC_INCLUDE_DIR} MATCHES "MONGOC_INCLUDE_DIR-NOTFOUND")
set(MONGOC_INCLUDE_DIR "${MONGOC_INCLUDE_DIR}/libmongoc-1.0")
ENDIF()
if (WIN32 AND NOT CYGWIN AND NOT MINGW)
if (MSVC)
find_library(MONGOC
NAMES
"mongoc-1.0"
HINTS
CMAKE_PREFIX_PATH
ENV MONGOC_DIR
ENV MONGOC_ROOT
ENV MONGOC_ROOT_DIR
PATH_SUFFIXES
bin
lib
)
if (NOT ${MONGOC} MATCHES "MONGOC-NOTFOUND")
mark_as_advanced(MONGOC)
set(MONGOC_LIBRARIES ${MONGOC} ws2_32)
find_file(MONGOC_DLL
NAMES
"libmongoc-1.0.dll"
HINTS
CMAKE_PREFIX_PATH
ENV MONGOC_DIR
ENV MONGOC_ROOT
ENV MONGOC_ROOT_DIR
PATH_SUFFIXES
bin
)
endif ()
else ()
# bother supporting this?
endif ()
else ()
find_library(MONGOC_LIBRARY
NAMES
"mongoc-1.0"
"libmongoc-1.0"
HINTS
CMAKE_PREFIX_PATH
ENV MONGOC_DIR
ENV MONGOC_ROOT
ENV MONGOC_ROOT_DIR
PATH_SUFFIXES
lib
)
if (NOT ${MONGOC_LIBRARY} MATCHES "MONGOC_LIBRARY-NOTFOUND")
mark_as_advanced(MONGOC_LIBRARY)
find_package(Threads REQUIRED)
set(MONGOC_LIBRARIES ${MONGOC_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
endif ()
endif ()
if (MONGOC_INCLUDE_DIR)
if (_MONGOC_VERSION)
set(MONGOC_VERSION "${_MONGOC_VERSION}")
elseif (MONGOC_INCLUDE_DIR AND EXISTS "${MONGOC_INCLUDE_DIR}/mongoc-version.h")
file(STRINGS "${MONGOC_INCLUDE_DIR}/mongoc-version.h" mongoc_version_str
REGEX "^#define[\t ]+MONGOC_VERSION[\t ]+\([0-9.]+\)[\t ]+$")
string(REGEX REPLACE "^.*MONGOC_VERSION[\t ]+\([0-9.]+\)[\t ]+$"
"\\1" MONGOC_VERSION "${mongoc_version_str}")
endif ()
endif ()
include(FindPackageHandleStandardArgs)
if (MONGOC_VERSION)
find_package_handle_standard_args(MONGOC
REQUIRED_VARS
MONGOC_LIBRARIES
MONGOC_INCLUDE_DIR
VERSION_VAR
MONGOC_VERSION
FAIL_MESSAGE
"Could NOT find MONGOC version"
)
else ()
find_package_handle_standard_args(MONGOC "Could NOT find MONGOC"
MONGOC_LIBRARIES
MONGOC_INCLUDE_DIR
)
endif ()
mark_as_advanced(MONGOC_INCLUDE_DIR MONGOC_LIBRARIES)