2014-09-11 00:25:07 -06:00
# Copyright (c) 2014, The Monero Project
#
# 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 00:22:49 -06:00
2014-10-06 07:00:06 -06: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 00:22:49 -06:00
2014-10-06 10:56:59 -06:00
find_package ( MiniUpnpc QUIET )
2014-09-11 00:22:49 -06:00
2014-10-06 07:00:06 -06:00
# FreeBSD doesn't play well with the local copy, so default to using shared
2014-10-06 15:54:48 -06:00
SET ( USE_SHARED_MINIUPNPC false )
2014-09-24 13:23:23 -06:00
# If we have the correct shared version and we're not building static, use it
2014-10-06 15:54:48 -06:00
IF ( STATIC )
2014-10-06 07:00:06 -06:00
SET ( USE_SHARED_MINIUPNPC false )
2014-10-06 15:54:48 -06:00
ELSEIF ( MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER )
SET ( USE_SHARED_MINIUPNPC true )
2014-09-24 13:23:23 -06:00
ENDIF ( )
2014-10-06 07:00:06 -06:00
if ( USE_SHARED_MINIUPNPC )
2014-09-10 12:01:30 -06:00
message ( STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}" )
2014-09-11 00:22:49 -06: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 10:14:57 -06:00
else ( )
2014-10-06 07:00:06 -06: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-09-09 06:03:42 -06: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 12:01:30 -06:00
add_subdirectory ( miniupnpc )
2014-04-09 06:14:35 -06:00
2014-09-09 06:03:42 -06: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 00:22:49 -06:00
set ( UPNP_STATIC true PARENT_SCOPE )
2014-09-11 05:28:49 -06:00
set ( UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE )
2014-09-10 10:14:57 -06:00
endif ( )
2014-10-06 07:00:06 -06:00
2014-10-06 10:51:03 -06:00
find_package ( Unbound )
2014-10-06 07:00:06 -06:00
2014-10-06 07:40:01 -06:00
IF ( !UNBOUND_INCLUDE_DIR OR STATIC )
2014-10-06 07:00:06 -06:00
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 )
2014-10-06 10:56:59 -06:00
FIND_PACKAGE ( OpenSSL QUIET )
2014-10-06 10:06:25 -06:00
IF ( !OPENSSL_LIBRARIES )
MESSAGE ( FATAL_ERROR "${BoldRed}Could not find the openssl library. Please make sure you have installed openssl or libssl-dev or the equivalent${ColourReset}" )
ELSE ( )
MESSAGE ( STATUS "Found openssl libraries" )
ENDIF ( )
2014-10-06 10:56:59 -06:00
FIND_PACKAGE ( Expat QUIET )
2014-10-06 10:06:25 -06:00
IF ( !EXPAT_LIBRARIES )
MESSAGE ( FATAL_ERROR "${BoldRed}Could not find the expat library. Please make sure you have installed libexpat or libexpat-dev or the equivalent${ColourReset}" )
ELSE ( )
MESSAGE ( STATUS "Found expat libraries" )
ENDIF ( )
2014-10-06 07:00:06 -06:00
IF ( MINGW )
2014-10-06 11:40:53 -06:00
set ( ENV{USE_WINSOCK} 1 )
2014-10-06 14:29:07 -06:00
set ( ENV{CMAKE_CURRENT_SOURCE_DIR} ${ CMAKE_CURRENT_SOURCE_DIR } )
set ( ENV{GCC_PREFIX} ${ GCC_PREFIX } )
set ( ENV{CMAKE_FIND_ROOT_PATH} ${ CMAKE_FIND_ROOT_PATH } )
2014-10-06 07:00:06 -06:00
EXTERNALPROJECT_ADD (
l i b u n b o u n d
2014-10-06 07:40:01 -06:00
P R E F I X $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d
U R L $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d /
2014-10-06 14:29:07 -06:00
C O N F I G U R E _ C O M M A N D $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d / m o n e r o - c o n f i g . s h
2014-10-06 09:19:51 -06:00
B U I L D _ C O M M A N D $ ( M A K E )
2014-10-06 07:40:01 -06:00
U P D A T E _ C O M M A N D " "
P A T C H _ C O M M A N D " "
2014-10-06 09:19:51 -06:00
I N S T A L L _ C O M M A N D $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b t o o l - - m o d e = i n s t a l l c p $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b u n b o u n d . l a $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d
2014-10-06 07:40:01 -06:00
L O G _ D O W N L O A D 1
L O G _ U P D A T E 1
L O G _ C O N F I G U R E 1
L O G _ B U I L D 1
L O G _ T E S T 1
L O G _ I N S T A L L 1
2014-10-06 07:00:06 -06:00
)
ELSEIF ( APPLE )
2014-10-06 07:40:01 -06:00
execute_process ( COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE )
2014-10-06 07:00:06 -06:00
EXTERNALPROJECT_ADD (
l i b u n b o u n d
2014-10-06 07:40:01 -06:00
P R E F I X $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d
U R L $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d /
2014-10-06 09:19:51 -06:00
C O N F I G U R E _ C O M M A N D $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d / c o n f i g u r e - - p r e f i x = $ { B R E W _ P R E F I X } - - e n a b l e - s h a r e d - - e n a b l e - s t a t i c - - d i s a b l e - g o s t - - d i s a b l e - r p a t h - - w i t h - l i b e v e n t = n o - - w i t h o u t - p y u n b o u n d - - w i t h o u t - p y t h o n m o d u l e - - w i t h o u t - p t h r e a d s - - w i t h - l i b u n b o u n d - o n l y
B U I L D _ C O M M A N D $ ( M A K E )
2014-10-06 07:40:01 -06:00
U P D A T E _ C O M M A N D " "
P A T C H _ C O M M A N D " "
2014-10-06 09:19:51 -06:00
I N S T A L L _ C O M M A N D $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b t o o l - - m o d e = i n s t a l l c p $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b u n b o u n d . l a $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d
2014-10-06 07:40:01 -06:00
L O G _ D O W N L O A D 1
L O G _ U P D A T E 1
L O G _ C O N F I G U R E 1
L O G _ B U I L D 1
L O G _ T E S T 1
L O G _ I N S T A L L 1
2014-10-06 07:00:06 -06:00
)
ELSE ( )
EXTERNALPROJECT_ADD (
l i b u n b o u n d
2014-10-06 07:40:01 -06:00
P R E F I X $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d
U R L $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d /
C O N F I G U R E _ C O M M A N D $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u n b o u n d / c o n f i g u r e - - d i s a b l e - s h a r e d - - e n a b l e - s t a t i c - - d i s a b l e - g o s t - - d i s a b l e - r p a t h - - w i t h - l i b e v e n t = n o - - w i t h o u t - p y u n b o u n d - - w i t h o u t - p y t h o n m o d u l e - - w i t h o u t - p t h r e a d s - - w i t h - l i b u n b o u n d - o n l y
2014-10-06 09:19:51 -06:00
B U I L D _ C O M M A N D $ ( M A K E )
2014-10-06 07:40:01 -06:00
U P D A T E _ C O M M A N D " "
P A T C H _ C O M M A N D " "
2014-10-06 09:19:51 -06:00
I N S T A L L _ C O M M A N D $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b t o o l - - m o d e = i n s t a l l c p $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d / l i b u n b o u n d . l a $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n b o u n d / s r c / l i b u n b o u n d - b u i l d
2014-10-06 07:40:01 -06:00
L O G _ D O W N L O A D 1
L O G _ U P D A T E 1
L O G _ C O N F I G U R E 1
L O G _ B U I L D 1
L O G _ T E S T 1
L O G _ I N S T A L L 1
2014-10-06 07:00:06 -06:00
)
ENDIF ( )
set ( UNBOUND_STATIC true PARENT_SCOPE )
2014-10-06 07:40:01 -06:00
set ( UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE )
2014-10-06 11:17:40 -06:00
set ( UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE )
2014-10-06 07:40:01 -06:00
ELSE ( )
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 ( )
2014-10-06 07:00:06 -06:00
ENDIF ( )
2014-11-01 10:05:26 -06:00
set ( NET_SKELETON_SRCS net_skeleton/net_skeleton.c )
add_library ( net_skeleton ${ NET_SKELETON_SRCS } )