2 # - Try to find libmaxminddb.
3 # Once done this will define
4 # MAXMINDDB_FOUND - System has libmaxminddb
5 # MAXMINDDB_INCLUDE_DIRS - The libmaxminddb include directories
6 # MAXMINDDB_LIBRARIES - The libraries needed to use libmaxminddb
7 # MAXMINDDB_DEFINITIONS - Compiler switches required for using libmaxminddb
8 # MAXMINDDB_DLL_DIR - (Windows) Path to the MaxMindDB DLL.
9 # MAXMINDDB_DLL - (Windows) Name of the MaxMindDB DLL.
11 IF (MAXMINDDB_INCLUDE_DIRS)
12 # Already in cache, be silent
13 SET(MAXMINDDB_FIND_QUIETLY TRUE)
14 ENDIF (MAXMINDDB_INCLUDE_DIRS)
16 INCLUDE(FindWSWinLibs)
17 FindWSWinLibs("libmaxminddb-.*" "MAXMINDDB_HINTS")
19 IF (NOT USE_REPOSITORY)
20 find_package(PkgConfig)
21 pkg_check_modules(PC_LIBMAXMINDDB QUIET libmaxminddb)
22 set(MAXMINDDB_DEFINITIONS ${PC_LIBMAXMINDDB_CFLAGS_OTHER})
25 FIND_PATH(MAXMINDDB_INCLUDE_DIR maxminddb.h
27 ${PC_LIBMAXMINDDB_INCLUDEDIR} ${PC_LIBMAXMINDDB_INCLUDE_DIRS}
28 "${MAXMINDDB_HINTS}/include"
29 PATH_SUFFIXES maxminddb
32 find_library(MAXMINDDB_LIBRARY
34 maxminddb libmaxminddb libmaxminddb-0
36 ${PC_LIBMAXMINDDB_LIBDIR} ${PC_LIBMAXMINDDB_LIBRARY_DIRS}
37 "${MAXMINDDB_HINTS}/lib"
40 include(FindPackageHandleStandardArgs)
41 # handle the QUIETLY and REQUIRED arguments and set MAXMINDDB_FOUND to TRUE
42 # if all listed variables are TRUE
43 find_package_handle_standard_args(MaxMindDB DEFAULT_MSG
44 MAXMINDDB_LIBRARY MAXMINDDB_INCLUDE_DIR)
47 INCLUDE(CMakePushCheckState)
48 CMAKE_PUSH_CHECK_STATE()
49 SET(MAXMINDDB_LIBRARIES ${MAXMINDDB_LIBRARY} )
50 SET(MAXMINDDB_INCLUDE_DIRS ${MAXMINDDB_INCLUDE_DIR} )
51 INCLUDE(CheckFunctionExists)
52 SET(CMAKE_REQUIRED_INCLUDES ${MAXMINDDB_INCLUDE_DIRS})
53 SET(CMAKE_REQUIRED_LIBRARIES ${MAXMINDDB_LIBRARIES})
54 CMAKE_POP_CHECK_STATE()
56 set ( MAXMINDDB_DLL_DIR "${MAXMINDDB_HINTS}/bin"
57 CACHE PATH "Path to the MaxMindDB DLL"
59 file( GLOB _MAXMINDDB_dll RELATIVE "${MAXMINDDB_DLL_DIR}"
60 "${MAXMINDDB_DLL_DIR}/libmaxminddb*.dll"
62 set ( MAXMINDDB_DLL ${_MAXMINDDB_dll}
63 # We're storing filenames only. Should we use STRING instead?
64 CACHE FILEPATH "MaxMindDB DLL file name"
66 mark_as_advanced( MAXMINDDB_DLL_DIR MAXMINDDB_DLL )
69 SET(MAXMINDDB_LIBRARIES )
70 SET(MAXMINDDB_INCLUDE_DIRS )
71 SET(MAXMINDDB_DLL_DIR )
73 ENDIF(MAXMINDDB_FOUND)
75 MARK_AS_ADVANCED( MAXMINDDB_LIBRARIES MAXMINDDB_INCLUDE_DIRS )