File: FindMicroHttpd.cmake

package info (click to toggle)
vzlogger 0.8.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,140 kB
  • sloc: cpp: 12,020; sh: 331; ansic: 157; makefile: 25
file content (106 lines) | stat: -rw-r--r-- 3,453 bytes parent folder | download | duplicates (2)
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
# -*- mode: cmake; -*-
# - Try to find libmicrohttpd include dirs and libraries
# Usage of this module as follows:
# This file defines:
# * MICROHTTPD_FOUND if protoc was found
# * MICROHTTPD_LIBRARY The lib to link to
# * MICROHTTPD_INCLUDE The include directories for libmicrohttpd.

message(STATUS "FindMicrohttpd check")
IF (NOT WIN32)
  include(FindPkgConfig)
  if ( PKG_CONFIG_FOUND )

     pkg_check_modules (PC_MICROHTTPD microhttpd>=0.9)

     set(MICROHTTPD_DEFINITIONS ${PC_MICROHTTPD_CFLAGS_OTHER})
  endif(PKG_CONFIG_FOUND)
endif (NOT WIN32)

#
# set defaults
SET(_microhttpd_HOME "/usr/local")
SET(_microhttpd_INCLUDE_SEARCH_DIRS
  ${CMAKE_INCLUDE_PATH}
  /usr/local/include
  /usr/include
  )

SET(_microhttpd_LIBRARIES_SEARCH_DIRS
  ${CMAKE_LIBRARY_PATH}
  /usr/local/lib
  /usr/lib
  )

##
if( "${MICROHTTPD_HOME}" STREQUAL "")
  if("" MATCHES "$ENV{MICROHTTPD_HOME}")
    message(STATUS "MICROHTTPD_HOME env is not set, setting it to /usr/local")
    set (MICROHTTPD_HOME ${_microhttpd_HOME})
  else("" MATCHES "$ENV{MICROHTTPD_HOME}")
    set (MICROHTTPD_HOME "$ENV{MICROHTTPD_HOME}")
  endif("" MATCHES "$ENV{MICROHTTPD_HOME}")
else( "${MICROHTTPD_HOME}" STREQUAL "")
  message(STATUS "MICROHTTPD_HOME is not empty: \"${MICROHTTPD_HOME}\"")
endif( "${MICROHTTPD_HOME}" STREQUAL "")
##

message(STATUS "Looking for microhttpd in ${MICROHTTPD_HOME}")

IF( NOT ${MICROHTTPD_HOME} STREQUAL "" )
    SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
    SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
    SET(_microhttpd_HOME ${MICROHTTPD_HOME})
ENDIF( NOT ${MICROHTTPD_HOME} STREQUAL "" )

IF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )
  SET(_microhttpd_INCLUDE_SEARCH_DIRS $ENV{MICROHTTPD_INCLUDEDIR} ${_microhttpd_INCLUDE_SEARCH_DIRS})
ENDIF( NOT $ENV{MICROHTTPD_INCLUDEDIR} STREQUAL "" )

IF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )
  SET(_microhttpd_LIBRARIES_SEARCH_DIRS $ENV{MICROHTTPD_LIBRARYDIR} ${_microhttpd_LIBRARIES_SEARCH_DIRS})
ENDIF( NOT $ENV{MICROHTTPD_LIBRARYDIR} STREQUAL "" )

IF( MICROHTTPD_HOME )
  SET(_microhttpd_INCLUDE_SEARCH_DIRS ${MICROHTTPD_HOME}/include ${_microhttpd_INCLUDE_SEARCH_DIRS})
  SET(_microhttpd_LIBRARIES_SEARCH_DIRS ${MICROHTTPD_HOME}/lib ${_microhttpd_LIBRARIES_SEARCH_DIRS})
  SET(_microhttpd_HOME ${MICROHTTPD_HOME})
ENDIF( MICROHTTPD_HOME )

# find the include files
FIND_PATH(MICROHTTPD_INCLUDE_DIR microhttpd.h
   HINTS
     ${_microhttpd_INCLUDE_SEARCH_DIRS}
     ${PC_MICROHTTPD_INCLUDEDIR}
     ${PC_MICROHTTPD_INCLUDE_DIRS}
    ${CMAKE_INCLUDE_PATH}
)

# locate the library
IF(WIN32)
  SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.lib)
ELSE(WIN32)
  SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.so)
  SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.a)
ENDIF(WIN32)
FIND_LIBRARY(MICROHTTPD_LIBRARY NAMES ${MICROHTTPD_LIBRARY_NAMES}
  HINTS
    ${_microhttpd_LIBRARIES_SEARCH_DIRS}
    ${PC_MICROHTTPD_LIBDIR}
    ${PC_MICROHTTPD_LIBRARY_DIRS}
)

# if the include and the program are found then we have it
IF(MICROHTTPD_INCLUDE_DIR AND MICROHTTPD_LIBRARY)
  SET(MICROHTTPD_FOUND "YES")
ENDIF(MICROHTTPD_INCLUDE_DIR AND MICROHTTPD_LIBRARY)

if( NOT WIN32)
  list(APPEND MICROHTTPD_LIBRARY "-lrt")
endif( NOT WIN32)

MARK_AS_ADVANCED(
  MICROHTTPD_FOUND
  MICROHTTPD_LIBRARY
  MICROHTTPD_INCLUDE_DIR
)