summaryrefslogtreecommitdiffstats
path: root/project/cmake/modules/FindMicroHttpd.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/modules/FindMicroHttpd.cmake')
-rw-r--r--project/cmake/modules/FindMicroHttpd.cmake125
1 files changed, 34 insertions, 91 deletions
diff --git a/project/cmake/modules/FindMicroHttpd.cmake b/project/cmake/modules/FindMicroHttpd.cmake
index f73dc77..7d011fa 100644
--- a/project/cmake/modules/FindMicroHttpd.cmake
+++ b/project/cmake/modules/FindMicroHttpd.cmake
@@ -1,106 +1,49 @@
1IF (NOT WIN32) 1#.rst:
2 include(FindPkgConfig) 2# FindMicroHttpd
3 if ( PKG_CONFIG_FOUND ) 3# --------------
4 4# Finds the MicroHttpd library
5 pkg_check_modules (MICROHTTPD libmicrohttpd>=0.4)
6
7 set(MICROHTTPD_DEFINITIONS ${MICROHTTPD_CFLAGS_OTHER})
8 endif(PKG_CONFIG_FOUND)
9endif (NOT WIN32)
10
11# 5#
12# set defaults 6# This will will define the following variables::
13if(NOT MICROHTTPD_FOUND) 7#
14 SET(_microhttpd_HOME "/usr/local") 8# MICROHTTPD_FOUND - system has MicroHttpd
15 SET(_microhttpd_INCLUDE_SEARCH_DIRS 9# MICROHTTPD_INCLUDE_DIRS - the MicroHttpd include directory
16 ${CMAKE_INCLUDE_PATH} 10# MICROHTTPD_LIBRARIES - the MicroHttpd libraries
17 /usr/local/include 11# MICROHTTPD_DEFINITIONS - the MicroHttpd definitions
18 /usr/include 12#
19 ) 13# and the following imported targets::
20 14#
21 SET(_microhttpd_LIBRARIES_SEARCH_DIRS 15# MicroHttpd::MicroHttpd - The MicroHttpd library
22 ${CMAKE_LIBRARY_PATH}
23 /usr/local/lib
24 /usr/lib
25 )
26
27 ##
28 if( "${MICROHTTPD_HOME}" STREQUAL "")
29 if("" MATCHES "$ENV{MICROHTTPD_HOME}")
30 message(STATUS "MICROHTTPD_HOME env is not set, setting it to /usr/local")
31 set (MICROHTTPD_HOME ${_microhttpd_HOME})
32 else("" MATCHES "$ENV{MICROHTTPD_HOME}")
33 set (MICROHTTPD_HOME "$ENV{MICROHTTPD_HOME}")
34 endif("" MATCHES "$ENV{MICROHTTPD_HOME}")
35 else( "${MICROHTTPD_HOME}" STREQUAL "")
36 message(STATUS "MICROHTTPD_HOME is not empty: \"${MICROHTTPD_HOME}\"")
37 endif( "${MICROHTTPD_HOME}" STREQUAL "")
38 ##
39
40 message(STATUS "Looking for microhttpd in ${MICROHTTPD_HOME}")
41
42 IF( NOT ${MICROHTTPD_HOME} STREQUAL "" )
43 SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
44 SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
45 SET(_microhttpd_HOME ${MICROHTTPD_HOME})
46 ENDIF( NOT ${MICROHTTPD_HOME} STREQUAL "" )
47
48 IF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )
49 SET(_microhttpd_INCLUDE_SEARCH_DIRS $ENV{MICROHTTPD_INCLUDEDIR} ${_microhttpd_INCLUDE_SEARCH_DIRS})
50 ENDIF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )
51 16
52 IF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" ) 17if(PKG_CONFIG_FOUND)
53 SET(_microhttpd_LIBRARIES_SEARCH_DIRS $ENV{MICROHTTPD_LIBRARYDIR} ${_microhttpd_LIBRARIES_SEARCH_DIRS}) 18 pkg_check_modules(PC_MICROHTTPD libmicrohttpd>=0.4 QUIET)
54 ENDIF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" ) 19endif()
55 20
56 IF( MICROHTTPD_HOME ) 21find_path(MICROHTTPD_INCLUDE_DIR NAMES microhttpd.h
57 SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS}) 22 PATHS ${PC_MICROHTTPD_INCLUDEDIR})
58 SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS}) 23find_library(MICROHTTPD_LIBRARY NAMES microhttpd libmicrohttpd
59 SET(_microhttpd_HOME ${MICROHTTPD_HOME}) 24 PATHS ${PC_MICROHTTPD_LIBDIR})
60 ENDIF( MICROHTTPD_HOME )
61 25
62 # find the include files 26set(MICROHTTPD_VERSION ${PC_MICROHTTPD_VERSION})
63 FIND_PATH(MICROHTTPD_INCLUDE_DIRS microhttpd.h
64 HINTS
65 ${_microhttpd_INCLUDE_SEARCH_DIRS}
66 ${PC_MICROHTTPD_INCLUDEDIR}
67 ${PC_MICROHTTPD_INCLUDE_DIRS}
68 ${CMAKE_INCLUDE_PATH}
69 )
70 27
71 # locate the library 28include(FindPackageHandleStandardArgs)
72 IF(WIN32) 29find_package_handle_standard_args(MicroHttpd
73 SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.lib) 30 REQUIRED_VARS MICROHTTPD_LIBRARY MICROHTTPD_INCLUDE_DIR
74 ELSE(WIN32) 31 VERSION_VAR MICROHTTPD_VERSION)
75 SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.a)
76 ENDIF(WIN32)
77 FIND_LIBRARY(MICROHTTPD_LIBRARIES NAMES ${MICROHTTPD_LIBRARY_NAMES}
78 HINTS
79 ${_microhttpd_LIBRARIES_SEARCH_DIRS}
80 ${PC_MICROHTTPD_LIBDIR}
81 ${PC_MICROHTTPD_LIBRARY_DIRS}
82 )
83 32
84 # if the include and the program are found then we have it 33if(MICROHTTPD_FOUND)
85 IF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES) 34 set(MICROHTTPD_LIBRARIES ${MICROHTTPD_LIBRARY})
86 SET(MICROHTTPD_FOUND "YES") 35 set(MICROHTTPD_INCLUDE_DIRS ${MICROHTTPD_INCLUDE_DIR})
87 ENDIF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES) 36 set(MICROHTTPD_DEFINITIONS -DHAVE_LIBMICROHTTPD=1)
88 37
89 if( NOT WIN32) 38 if(NOT WIN32)
90 find_library(GCRYPT_LIBRARY gcrypt) 39 find_library(GCRYPT_LIBRARY gcrypt)
91 find_library(GPGERROR_LIBRARY gpg-error) 40 find_library(GPGERROR_LIBRARY gpg-error)
92 list(APPEND MICROHTTPD_LIBRARIES ${GCRYPT_LIBRARY} ${GPGERROR_LIBRARY}) 41 list(APPEND MICROHTTPD_LIBRARIES ${GCRYPT_LIBRARY} ${GPGERROR_LIBRARY})
42 mark_as_advanced(GCRYPT_LIBRARY GPGERROR_LIBRARY)
93 if(NOT APPLE AND NOT CORE_SYSTEM_NAME STREQUAL android) 43 if(NOT APPLE AND NOT CORE_SYSTEM_NAME STREQUAL android)
94 list(APPEND MICROHTTPD_LIBRARIES "-lrt") 44 list(APPEND MICROHTTPD_LIBRARIES "-lrt")
95 endif() 45 endif()
96 endif( NOT WIN32) 46 endif()
97endif() 47endif()
98 48
99list(APPEND MICROHTTPD_DEFINITIONS -DHAVE_LIBMICROHTTPD=1) 49mark_as_advanced(MICROHTTPD_LIBRARY MICROHTTPD_INCLUDE_DIR)
100
101MARK_AS_ADVANCED(
102 MICROHTTPD_FOUND
103 MICROHTTPD_LIBRARIES
104 MICROHTTPD_DEFINITIONS
105 MICROHTTPD_INCLUDE_DIRS
106)