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.cmake106
1 files changed, 106 insertions, 0 deletions
diff --git a/project/cmake/modules/FindMicroHttpd.cmake b/project/cmake/modules/FindMicroHttpd.cmake
new file mode 100644
index 0000000..f73dc77
--- /dev/null
+++ b/project/cmake/modules/FindMicroHttpd.cmake
@@ -0,0 +1,106 @@
1IF (NOT WIN32)
2 include(FindPkgConfig)
3 if ( PKG_CONFIG_FOUND )
4
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#
12# set defaults
13if(NOT MICROHTTPD_FOUND)
14 SET(_microhttpd_HOME "/usr/local")
15 SET(_microhttpd_INCLUDE_SEARCH_DIRS
16 ${CMAKE_INCLUDE_PATH}
17 /usr/local/include
18 /usr/include
19 )
20
21 SET(_microhttpd_LIBRARIES_SEARCH_DIRS
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
52 IF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )
53 SET(_microhttpd_LIBRARIES_SEARCH_DIRS $ENV{MICROHTTPD_LIBRARYDIR} ${_microhttpd_LIBRARIES_SEARCH_DIRS})
54 ENDIF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )
55
56 IF( MICROHTTPD_HOME )
57 SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
58 SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
59 SET(_microhttpd_HOME ${MICROHTTPD_HOME})
60 ENDIF( MICROHTTPD_HOME )
61
62 # find the include files
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
71 # locate the library
72 IF(WIN32)
73 SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.lib)
74 ELSE(WIN32)
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
84 # if the include and the program are found then we have it
85 IF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES)
86 SET(MICROHTTPD_FOUND "YES")
87 ENDIF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES)
88
89 if( NOT WIN32)
90 find_library(GCRYPT_LIBRARY gcrypt)
91 find_library(GPGERROR_LIBRARY gpg-error)
92 list(APPEND MICROHTTPD_LIBRARIES ${GCRYPT_LIBRARY} ${GPGERROR_LIBRARY})
93 if(NOT APPLE AND NOT CORE_SYSTEM_NAME STREQUAL android)
94 list(APPEND MICROHTTPD_LIBRARIES "-lrt")
95 endif()
96 endif( NOT WIN32)
97endif()
98
99list(APPEND MICROHTTPD_DEFINITIONS -DHAVE_LIBMICROHTTPD=1)
100
101MARK_AS_ADVANCED(
102 MICROHTTPD_FOUND
103 MICROHTTPD_LIBRARIES
104 MICROHTTPD_DEFINITIONS
105 MICROHTTPD_INCLUDE_DIRS
106)