From 8cdf8dec703d882b46ca50a769fabb95ffc48e2c Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 24 Nov 2016 21:27:41 +0100 Subject: sync with upstream --- project/cmake/modules/FindMicroHttpd.cmake | 125 ++++++++--------------------- 1 file changed, 34 insertions(+), 91 deletions(-) (limited to 'project/cmake/modules/FindMicroHttpd.cmake') 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 @@ -IF (NOT WIN32) - include(FindPkgConfig) - if ( PKG_CONFIG_FOUND ) - - pkg_check_modules (MICROHTTPD libmicrohttpd>=0.4) - - set(MICROHTTPD_DEFINITIONS ${MICROHTTPD_CFLAGS_OTHER}) - endif(PKG_CONFIG_FOUND) -endif (NOT WIN32) - +#.rst: +# FindMicroHttpd +# -------------- +# Finds the MicroHttpd library # -# set defaults -if(NOT MICROHTTPD_FOUND) - 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 "" ) +# This will will define the following variables:: +# +# MICROHTTPD_FOUND - system has MicroHttpd +# MICROHTTPD_INCLUDE_DIRS - the MicroHttpd include directory +# MICROHTTPD_LIBRARIES - the MicroHttpd libraries +# MICROHTTPD_DEFINITIONS - the MicroHttpd definitions +# +# and the following imported targets:: +# +# MicroHttpd::MicroHttpd - The MicroHttpd library - 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(PKG_CONFIG_FOUND) + pkg_check_modules(PC_MICROHTTPD libmicrohttpd>=0.4 QUIET) +endif() - 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_path(MICROHTTPD_INCLUDE_DIR NAMES microhttpd.h + PATHS ${PC_MICROHTTPD_INCLUDEDIR}) +find_library(MICROHTTPD_LIBRARY NAMES microhttpd libmicrohttpd + PATHS ${PC_MICROHTTPD_LIBDIR}) - # find the include files - FIND_PATH(MICROHTTPD_INCLUDE_DIRS microhttpd.h - HINTS - ${_microhttpd_INCLUDE_SEARCH_DIRS} - ${PC_MICROHTTPD_INCLUDEDIR} - ${PC_MICROHTTPD_INCLUDE_DIRS} - ${CMAKE_INCLUDE_PATH} - ) +set(MICROHTTPD_VERSION ${PC_MICROHTTPD_VERSION}) - # locate the library - IF(WIN32) - SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.lib) - ELSE(WIN32) - SET(MICROHTTPD_LIBRARY_NAMES ${MICROHTTPD_LIBRARY_NAMES} libmicrohttpd.a) - ENDIF(WIN32) - FIND_LIBRARY(MICROHTTPD_LIBRARIES NAMES ${MICROHTTPD_LIBRARY_NAMES} - HINTS - ${_microhttpd_LIBRARIES_SEARCH_DIRS} - ${PC_MICROHTTPD_LIBDIR} - ${PC_MICROHTTPD_LIBRARY_DIRS} - ) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MicroHttpd + REQUIRED_VARS MICROHTTPD_LIBRARY MICROHTTPD_INCLUDE_DIR + VERSION_VAR MICROHTTPD_VERSION) - # if the include and the program are found then we have it - IF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES) - SET(MICROHTTPD_FOUND "YES") - ENDIF(MICROHTTPD_INCLUDE_DIRS AND MICROHTTPD_LIBRARIES) +if(MICROHTTPD_FOUND) + set(MICROHTTPD_LIBRARIES ${MICROHTTPD_LIBRARY}) + set(MICROHTTPD_INCLUDE_DIRS ${MICROHTTPD_INCLUDE_DIR}) + set(MICROHTTPD_DEFINITIONS -DHAVE_LIBMICROHTTPD=1) - if( NOT WIN32) + if(NOT WIN32) find_library(GCRYPT_LIBRARY gcrypt) find_library(GPGERROR_LIBRARY gpg-error) list(APPEND MICROHTTPD_LIBRARIES ${GCRYPT_LIBRARY} ${GPGERROR_LIBRARY}) + mark_as_advanced(GCRYPT_LIBRARY GPGERROR_LIBRARY) if(NOT APPLE AND NOT CORE_SYSTEM_NAME STREQUAL android) list(APPEND MICROHTTPD_LIBRARIES "-lrt") endif() - endif( NOT WIN32) + endif() endif() -list(APPEND MICROHTTPD_DEFINITIONS -DHAVE_LIBMICROHTTPD=1) - -MARK_AS_ADVANCED( - MICROHTTPD_FOUND - MICROHTTPD_LIBRARIES - MICROHTTPD_DEFINITIONS - MICROHTTPD_INCLUDE_DIRS -) +mark_as_advanced(MICROHTTPD_LIBRARY MICROHTTPD_INCLUDE_DIR) -- cgit v1.2.3