2015-01-02 17:52:46 +01:00
# Copyright (c) 2014-2015, The Monero Project
2014-09-11 08:25:07 +02:00
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
2014-09-11 08:22:49 +02:00
2014-10-06 15:00:06 +02:00
# 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.
2014-09-11 08:22:49 +02:00
2015-03-26 12:28:31 +01:00
find_package ( Miniupnpc QUIET )
2014-09-11 08:22:49 +02:00
2014-10-06 15:00:06 +02:00
# FreeBSD doesn't play well with the local copy, so default to using shared
2014-10-22 21:17:32 +02:00
set ( USE_SHARED_MINIUPNPC false )
2014-09-24 21:23:23 +02:00
# If we have the correct shared version and we're not building static, use it
2014-10-22 21:17:32 +02:00
if ( STATIC )
set ( USE_SHARED_MINIUPNPC false )
elseif ( MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER )
set ( USE_SHARED_MINIUPNPC true )
endif ( )
2014-09-24 21:23:23 +02:00
2014-10-06 15:00:06 +02:00
if ( USE_SHARED_MINIUPNPC )
2014-09-10 20:01:30 +02:00
message ( STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}" )
2014-09-11 08:22:49 +02:00
set ( UPNP_STATIC false PARENT_SCOPE )
set ( UPNP_INCLUDE ${ MINIUPNP_INCLUDE_DIR } PARENT_SCOPE )
set ( UPNP_LIBRARIES ${ MINIUPNP_LIBRARY } PARENT_SCOPE )
2014-09-10 18:14:57 +02:00
else ( )
2014-10-06 15:00:06 +02:00
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 ( )
2014-10-22 21:17:32 +02:00
2014-09-09 14:03:42 +02:00
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" )
2014-09-10 20:01:30 +02:00
add_subdirectory ( miniupnpc )
2014-04-09 14:14:35 +02:00
2014-09-09 14:03:42 +02:00
set_property ( TARGET upnpc-static PROPERTY FOLDER "external" )
if ( MSVC )
set_property ( TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267" )
elseif ( NOT MSVC )
set_property ( TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value" )
endif ( )
2014-09-11 08:22:49 +02:00
set ( UPNP_STATIC true PARENT_SCOPE )
2014-09-11 13:28:49 +02:00
set ( UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE )
2014-09-10 18:14:57 +02:00
endif ( )
2014-10-06 15:00:06 +02:00
2014-10-06 18:51:03 +02:00
find_package ( Unbound )
2014-10-06 15:00:06 +02:00
2014-10-22 21:17:32 +02:00
if ( NOT UNBOUND_INCLUDE_DIR OR STATIC )
2014-10-22 00:39:15 +02:00
add_subdirectory ( unbound )
2014-10-06 18:06:25 +02:00
2014-10-06 15:00:06 +02:00
set ( UNBOUND_STATIC true PARENT_SCOPE )
2014-10-22 00:39:15 +02:00
set ( UNBOUND_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/unbound/libunbound" PARENT_SCOPE )
set ( UNBOUND_LIBRARY "unbound" PARENT_SCOPE )
2014-10-24 21:29:56 +02:00
set ( UNBOUND_LIBRARY_DIRS "${LIBEVENT2_LIBDIR}" PARENT_SCOPE )
2014-10-22 21:17:32 +02:00
else ( )
message ( STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}" )
if ( UNBOUND_LIBRARIES )
message ( STATUS "Found libunbound shared library" )
2014-10-06 15:40:01 +02:00
set ( UNBOUND_STATIC false PARENT_SCOPE )
set ( UNBOUND_INCLUDE ${ UNBOUND_INCLUDE_DIR } PARENT_SCOPE )
set ( UNBOUND_LIBRARY ${ UNBOUND_LIBRARIES } PARENT_SCOPE )
2014-10-22 00:39:15 +02:00
set ( UNBOUND_LIBRARY_DIRS "" PARENT_SCOPE )
2014-10-22 21:17:32 +02:00
else ( )
2014-10-21 19:33:26 +02:00
die ( "Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent" )
2014-10-22 21:17:32 +02:00
endif ( )
endif ( )