mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 00:07:38 +00:00
build libunbound from external if no local libunbound or for static builds
This commit is contained in:
parent
add1a608dd
commit
cee87473ad
5 changed files with 270 additions and 232 deletions
|
@ -92,8 +92,17 @@ if (UNIX AND NOT APPLE)
|
|||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
# Find unbound - don't move this to the end, cmake is weird about this
|
||||
find_package(Unbound REQUIRED)
|
||||
add_subdirectory(external)
|
||||
|
||||
# Final setup for miniupnpc
|
||||
if(UPNP_STATIC)
|
||||
add_definitions("-DUPNP_STATIC")
|
||||
else()
|
||||
add_definitions("-DUPNP_DYNAMIC")
|
||||
include_directories(${UPNP_INCLUDE})
|
||||
endif()
|
||||
|
||||
# Final setup for libunbound
|
||||
include_directories(${UNBOUND_INCLUDE})
|
||||
|
||||
if(MSVC)
|
||||
|
@ -215,15 +224,5 @@ else()
|
|||
add_custom_target(version ALL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(external)
|
||||
|
||||
# Final setup for miniupnpc
|
||||
if(UPNP_STATIC)
|
||||
add_definitions("-DUPNP_STATIC")
|
||||
else()
|
||||
add_definitions("-DUPNP_DYNAMIC")
|
||||
include_directories(${UPNP_INCLUDE})
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
|
185
cmake/FindMiniupnpc.cmake
Normal file
185
cmake/FindMiniupnpc.cmake
Normal file
|
@ -0,0 +1,185 @@
|
|||
# --------------------------------- FindMiniupnpc Start ---------------------------------
|
||||
# Locate miniupnp library
|
||||
# This module defines
|
||||
# MINIUPNP_FOUND, if false, do not try to link to miniupnp
|
||||
# MINIUPNP_LIBRARY, the miniupnp variant
|
||||
# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
|
||||
# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is
|
||||
# pre 1.6
|
||||
# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is
|
||||
# pre 1.5
|
||||
#
|
||||
# Note that the expected include convention is
|
||||
# #include "miniupnpc.h"
|
||||
# and not
|
||||
# #include <miniupnpc/miniupnpc.h>
|
||||
# This is because, the miniupnpc location is not standardized and may exist
|
||||
# in locations other than miniupnpc/
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011 Mark Vejvoda
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distributed this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
# Already in cache, be silent
|
||||
set(MINIUPNP_FIND_QUIETLY TRUE)
|
||||
endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
|
||||
find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
|
||||
PATH_SUFFIXES miniupnpc)
|
||||
find_library(MINIUPNP_LIBRARY miniupnpc)
|
||||
|
||||
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
set (MINIUPNP_FOUND TRUE)
|
||||
endif ()
|
||||
|
||||
if (MINIUPNP_FOUND)
|
||||
include(CheckCXXSourceRuns)
|
||||
if (NOT MINIUPNP_FIND_QUIETLY)
|
||||
message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}")
|
||||
message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}")
|
||||
endif (NOT MINIUPNP_FIND_QUIETLY)
|
||||
|
||||
message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}")
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
|
||||
GetUPNPUrls (&urls, &data, \"myurl\",0);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
struct UPNPDev *devlist = NULL;
|
||||
int upnp_delay = 5000;
|
||||
const char *upnp_multicastif = NULL;
|
||||
const char *upnp_minissdpdsock = NULL;
|
||||
int upnp_sameport = 0;
|
||||
int upnp_ipv6 = 0;
|
||||
int upnp_error = 0;
|
||||
devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_7)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
struct UPNPDev *devlist = NULL;
|
||||
int upnp_delay = 5000;
|
||||
const char *upnp_multicastif = NULL;
|
||||
const char *upnp_minissdpdsock = NULL;
|
||||
int upnp_sameport = 0;
|
||||
int upnp_ipv6 = 0;
|
||||
int upnp_error = 0;
|
||||
devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_6)
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
int main()
|
||||
{
|
||||
char externalIP[16] = \"\";
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_1_5_OR_HIGHER)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
int main()
|
||||
{
|
||||
char externalIP[16] = \"\";
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_5)
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF(MINIUPNPC_VERSION_PRE1_5)
|
||||
message(STATUS "Found miniupnpc version is pre v1.5")
|
||||
ENDIF()
|
||||
IF(MINIUPNPC_VERSION_PRE1_6)
|
||||
message(STATUS "Found miniupnpc version is pre v1.6")
|
||||
ENDIF()
|
||||
IF(MINIUPNPC_VERSION_PRE1_7)
|
||||
message(STATUS "Found miniupnpc version is pre v1.7")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7)
|
||||
IF(MINIUPNPC_VERSION_1_5_OR_HIGHER)
|
||||
message(STATUS "Found miniupnpc version is v1.5 or higher")
|
||||
ELSE()
|
||||
message(STATUS "Found miniupnpc version is v1.7 or higher")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
else ()
|
||||
message (STATUS "Could not find miniupnp")
|
||||
endif ()
|
||||
|
||||
MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY)
|
||||
# --------------------------------- FindMiniupnpc End ---------------------------------
|
|
@ -37,25 +37,4 @@ FIND_PATH(UNBOUND_INCLUDE_DIR
|
|||
/usr/
|
||||
)
|
||||
|
||||
if(STATIC)
|
||||
if(MINGW)
|
||||
find_library(UNBOUND_LIBRARIES libunbound.dll.a)
|
||||
else()
|
||||
find_library(UNBOUND_LIBRARIES libunbound.a)
|
||||
endif()
|
||||
else()
|
||||
find_library(UNBOUND_LIBRARIES unbound)
|
||||
endif()
|
||||
|
||||
IF(UNBOUND_INCLUDE_DIR)
|
||||
MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}")
|
||||
IF(UNBOUND_LIBRARIES)
|
||||
MESSAGE(STATUS "Found libunbound library")
|
||||
set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR})
|
||||
set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES})
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}")
|
||||
ENDIF()
|
||||
find_library(UNBOUND_LIBRARIES unbound)
|
||||
|
|
268
external/CMakeLists.txt
vendored
268
external/CMakeLists.txt
vendored
|
@ -28,216 +28,36 @@
|
|||
#
|
||||
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
# --------------------------------- FindMiniupnpc Start ---------------------------------
|
||||
# Locate miniupnp library
|
||||
# This module defines
|
||||
# MINIUPNP_FOUND, if false, do not try to link to miniupnp
|
||||
# MINIUPNP_LIBRARY, the miniupnp variant
|
||||
# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family)
|
||||
# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is
|
||||
# pre 1.6
|
||||
# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is
|
||||
# pre 1.5
|
||||
#
|
||||
# Note that the expected include convention is
|
||||
# #include "miniupnpc.h"
|
||||
# and not
|
||||
# #include <miniupnpc/miniupnpc.h>
|
||||
# This is because, the miniupnpc location is not standardized and may exist
|
||||
# in locations other than miniupnpc/
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011 Mark Vejvoda
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distributed this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
# This is broken up into two parts: first we check for miniupnp, compile it if we can't
|
||||
# find it, and thereafter we check for libunbound, and compile it if we can't find it.
|
||||
# We always compile if we are building statically to reduce static dependency issues...
|
||||
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
|
||||
# others.
|
||||
|
||||
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
# Already in cache, be silent
|
||||
set(MINIUPNP_FIND_QUIETLY TRUE)
|
||||
endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
find_package(MiniUpnpc REQUIRED)
|
||||
|
||||
find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h
|
||||
PATH_SUFFIXES miniupnpc)
|
||||
find_library(MINIUPNP_LIBRARY miniupnpc)
|
||||
|
||||
if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY)
|
||||
set (MINIUPNP_FOUND TRUE)
|
||||
endif ()
|
||||
|
||||
if (MINIUPNP_FOUND)
|
||||
include(CheckCXXSourceRuns)
|
||||
if (NOT MINIUPNP_FIND_QUIETLY)
|
||||
message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}")
|
||||
message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}")
|
||||
endif (NOT MINIUPNP_FIND_QUIETLY)
|
||||
|
||||
message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}")
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
|
||||
GetUPNPUrls (&urls, &data, \"myurl\",0);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
struct UPNPDev *devlist = NULL;
|
||||
int upnp_delay = 5000;
|
||||
const char *upnp_multicastif = NULL;
|
||||
const char *upnp_minissdpdsock = NULL;
|
||||
int upnp_sameport = 0;
|
||||
int upnp_ipv6 = 0;
|
||||
int upnp_error = 0;
|
||||
devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_7)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
struct UPNPDev *devlist = NULL;
|
||||
int upnp_delay = 5000;
|
||||
const char *upnp_multicastif = NULL;
|
||||
const char *upnp_minissdpdsock = NULL;
|
||||
int upnp_sameport = 0;
|
||||
int upnp_ipv6 = 0;
|
||||
int upnp_error = 0;
|
||||
devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_6)
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
int main()
|
||||
{
|
||||
char externalIP[16] = \"\";
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_1_5_OR_HIGHER)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY})
|
||||
check_cxx_source_runs("
|
||||
#include <miniwget.h>
|
||||
#include <miniupnpc.h>
|
||||
#include <upnpcommands.h>
|
||||
#include <stdio.h>
|
||||
static struct UPNPUrls urls;
|
||||
static struct IGDdatas data;
|
||||
int main()
|
||||
{
|
||||
char externalIP[16] = \"\";
|
||||
UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP);
|
||||
|
||||
return 0;
|
||||
}"
|
||||
MINIUPNPC_VERSION_PRE1_5)
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF(MINIUPNPC_VERSION_PRE1_5)
|
||||
message(STATUS "Found miniupnpc version is pre v1.5")
|
||||
ENDIF()
|
||||
IF(MINIUPNPC_VERSION_PRE1_6)
|
||||
message(STATUS "Found miniupnpc version is pre v1.6")
|
||||
ENDIF()
|
||||
IF(MINIUPNPC_VERSION_PRE1_7)
|
||||
message(STATUS "Found miniupnpc version is pre v1.7")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7)
|
||||
IF(MINIUPNPC_VERSION_1_5_OR_HIGHER)
|
||||
message(STATUS "Found miniupnpc version is v1.5 or higher")
|
||||
ELSE()
|
||||
message(STATUS "Found miniupnpc version is v1.7 or higher")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
else ()
|
||||
message (STATUS "Could not find miniupnp")
|
||||
endif ()
|
||||
|
||||
MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY)
|
||||
# --------------------------------- FindMiniupnpc End ---------------------------------
|
||||
|
||||
# And now on to the Monero part of things
|
||||
|
||||
# FreeBSD doesn't play well with the local copy
|
||||
SET(USE_SHARED false)
|
||||
# FreeBSD doesn't play well with the local copy, so default to using shared
|
||||
SET(USE_SHARED_MINIUPNPC true)
|
||||
|
||||
# If we have the correct shared version and we're not building static, use it
|
||||
IF(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER AND !STATIC)
|
||||
SET(USE_SHARED true)
|
||||
IF(!MINIUPNP_FOUND OR !MINIUPNPC_VERSION_1_7_OR_HIGHER OR STATIC)
|
||||
SET(USE_SHARED_MINIUPNPC false)
|
||||
ENDIF()
|
||||
|
||||
# If we're on FreeBSD
|
||||
IF(FREEBSD)
|
||||
SET(USE_SHARED true)
|
||||
ENDIF()
|
||||
|
||||
if(USE_SHARED)
|
||||
if(USE_SHARED_MINIUPNPC)
|
||||
message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}")
|
||||
|
||||
set(UPNP_STATIC false PARENT_SCOPE)
|
||||
set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE)
|
||||
set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "Using static miniupnpc from external")
|
||||
|
||||
if(STATIC)
|
||||
message(STATUS "Using miniupnpc from local source tree for static build")
|
||||
else()
|
||||
message(STATUS "Using miniupnpc from local source tree (/external/miniupnpc)")
|
||||
endif()
|
||||
|
||||
set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library")
|
||||
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library")
|
||||
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables")
|
||||
|
@ -253,3 +73,57 @@ else()
|
|||
set(UPNP_STATIC true PARENT_SCOPE)
|
||||
set(UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
find_package(Unbound REQUIRED)
|
||||
|
||||
IF(UNBOUND_INCLUDE_DIR)
|
||||
MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}")
|
||||
IF(UNBOUND_LIBRARIES)
|
||||
MESSAGE(STATUS "Found libunbound shared library")
|
||||
set(UNBOUND_STATIC false PARENT_SCOPE)
|
||||
set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE)
|
||||
set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}")
|
||||
ENDIF()
|
||||
ELSE
|
||||
if(STATIC)
|
||||
message(STATUS "Using libunbound from local source tree for static build")
|
||||
else()
|
||||
message(STATUS "Using libunbound from local source tree (/external/unbound)")
|
||||
endif()
|
||||
|
||||
INCLUDE(ExternalProject)
|
||||
|
||||
FIND_PACKAGE(OpenSSL REQUIRED)
|
||||
FIND_PACKAGE(Expat REQUIRED)
|
||||
|
||||
IF(MINGW)
|
||||
EXTERNALPROJECT_ADD(
|
||||
libunbound
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound
|
||||
BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound
|
||||
CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only
|
||||
BUILD_COMMAND make
|
||||
)
|
||||
ELSEIF(APPLE)
|
||||
EXTERNALPROJECT_ADD(
|
||||
libunbound
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound
|
||||
BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound
|
||||
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=$(brew --prefix) --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only
|
||||
BUILD_COMMAND make
|
||||
)
|
||||
ELSE()
|
||||
EXTERNALPROJECT_ADD(
|
||||
libunbound
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound
|
||||
BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound
|
||||
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only
|
||||
BUILD_COMMAND make
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
set(UNBOUND_STATIC true PARENT_SCOPE)
|
||||
set(UNBOUND_LIBRARY unbound-static PARENT_SCOPE)
|
||||
ENDIF()
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#include "common/dns_utils.h"
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <unbound.h>
|
||||
// check local first (in the event of static or in-source compilation of libunbound)
|
||||
#include "unbound.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "include_base_utils.h"
|
||||
|
|
Loading…
Reference in a new issue