From 208c1a04deedbc268f51830d208c261d31b58fcb Mon Sep 17 00:00:00 2001 From: casey langen Date: Fri, 25 Jan 2019 10:00:47 -0800 Subject: [PATCH] Added code back to conditionally build libmicrohttpd -- but this time for macOS. --- src/plugins/server/CMakeLists.txt | 35 ++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/plugins/server/CMakeLists.txt b/src/plugins/server/CMakeLists.txt index 290e88b60..398c6b02e 100644 --- a/src/plugins/server/CMakeLists.txt +++ b/src/plugins/server/CMakeLists.txt @@ -22,15 +22,34 @@ set (server_LINK_LIBS ${BOOST_LINK_LIBS}) include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include") -set(EXTRA_LIBS "") -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") - set(EXTRA_LIBS "gnutls") -endif() - if (${LINK_STATICALLY} MATCHES "true") - # prefer static libraries on mac to make redist easier - find_library(MICROHTTPDLIB NAMES libmicrohttpd.a microhttpd) - target_link_libraries(server ${server_LINK_LIBS} ${MICROHTTPDLIB} z ${EXTRA_LIBS}) + # libmicrohttpd on macOS now depends on `gnutls`. when we build statically, + # we also need to build libmicrohttpd ourselves and disable TLS to avoid this + # homebrew-only dependency + set(EXTRA_OBJS "") + set(MICROHTTPDLIB "") + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + include (ExternalProject) + + ExternalProject_Add(libmicrohttpd + URL https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.62.tar.gz + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND ./configure --enable-https=no --disable-curl --prefix=${CMAKE_CURRENT_SOURCE_DIR}/microhttpd/ + BUILD_COMMAND make + INSTALL_COMMAND make install + TEST_COMMAND "") + + add_dependencies(server libmicrohttpd) + include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/microhttpd/include") + file(GLOB EXTRA_OBJS "${CMAKE_CURRENT_SOURCE_DIR}/libmicrohttpd-prefix/src/libmicrohttpd/src/microhttpd/.libs/*.o") + else() + find_library(MICROHTTPDLIB NAMES libmicrohttpd.a microhttpd) + endif() + target_link_libraries(server ${server_LINK_LIBS} ${MICROHTTPDLIB} z ${EXTRA_OBJS}) else() + set(EXTRA_LIBS "") + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(EXTRA_LIBS "gnutls") + endif() target_link_libraries(server ${server_LINK_LIBS} microhttpd z ${EXTRA_LIBS}) endif()