@ -37,55 +37,109 @@ set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/thirdparty)
OPTION ( BUILD_SHARED_LIBS "BUILD Shared Library" OFF )
OPTION ( BUILD_SHARED_LIBS "BUILD Shared Library" OFF )
# N 2 n s p e c i f i c p a r a m s
# N 2 n s p e c i f i c p a r a m s
OPTION ( N2N_OPTION_USE_PTHREAD "USE PTHREAD Library" ON )
OPTION ( N2N_OPTION_USE_PTHREAD "USE PTHREAD Library" OFF )
OPTION ( N2N_OPTION_USE_OPENSSL "USE OPENSSL Library" OFF )
OPTION ( N2N_OPTION_USE_OPENSSL "USE OPENSSL Library" OFF )
OPTION ( N2N_OPTION_USE_CAPLIB "USE CAP Library" OFF )
OPTION ( N2N_OPTION_USE_PCAPLIB "USE PCAP Library" OFF )
OPTION ( N2N_OPTION_USE_PCAPLIB "USE PCAP Library" OFF )
OPTION ( N2N_OPTION_USE_ZSTD "USE ZSTD Library" OFF )
OPTION ( N2N_OPTION_USE_ZSTD "USE ZSTD Library" OFF )
OPTION ( N2N_OPTION_USE_PORTMAPPING "USE MINIUPNP and NATPMP Libraries" ON )
OPTION ( N2N_OPTION_USE_PORTMAPPING "USE MINIUPNP and NATPMP Libraries" OFF )
if ( N2N_OPTION_USE_PTHREAD )
if ( N2N_OPTION_USE_PTHREAD )
find_library ( PTHREAD_LIB pthread )
find_library ( PTHREAD_LIB pthread )
if ( PTHREAD_LIB )
if ( NOT PTHREAD_LIB )
ADD_DEFINITIONS ( "-DHAVE_PTHREAD" )
MESSAGE ( FATAL_ERROR "libpthread not found." )
else ( )
MESSAGE ( WARNING "libpthread not found." )
set ( N2N_OPTION_USE_PTHREAD OFF )
endif ( PTHREAD_LIB )
endif ( PTHREAD_LIB )
MESSAGE ( INFO "Using libpthread." )
ADD_DEFINITIONS ( "-DHAVE_PTHREAD" )
target_link_libraries ( n2n pthread )
endif ( N2N_OPTION_USE_PTHREAD )
endif ( N2N_OPTION_USE_PTHREAD )
if ( NOT DEFINED N2N_OPTION_USE_OPENSSL )
set ( N2N_OPTION_USE_OPENSSL OFF )
endif ( NOT DEFINED N2N_OPTION_USE_OPENSSL )
if ( N2N_OPTION_USE_OPENSSL )
if ( N2N_OPTION_USE_OPENSSL )
find_package ( OpenSSL QUIET )
find_package ( OpenSSL QUIET )
if ( NOT OPENSSL_FOUND )
if ( NOT OPENSSL_FOUND )
MESSAGE ( WARNING "OpenSSL not found, Use built-in AES." )
MESSAGE ( FATAL_ERROR "OpenSSL not found." )
set ( N2N_OPTION_USE_OPENSSL OFF )
else ( )
MESSAGE ( STATUS "Found OpenSSL ${OPENSSL_VERSION}" )
string ( COMPARE GREATER "${OPENSSL_VERSION}" "1.1" OPENSSL_V11 )
if ( OPENSSL_V11 )
MESSAGE ( STATUS "Use OpenSSL With -DHAVE_OPENSSL_1_1" )
include_directories ( ${ OPENSSL_INCLUDE_DIR } )
add_definitions ( -DHAVE_OPENSSL_1_1 )
endif ( )
endif ( NOT OPENSSL_FOUND )
endif ( NOT OPENSSL_FOUND )
MESSAGE ( STATUS "Found OpenSSL ${OPENSSL_VERSION}" )
string ( COMPARE GREATER "${OPENSSL_VERSION}" "1.1" OPENSSL_V11 )
if ( NOT OPENSSL_V11 )
MESSAGE ( FATAL_ERROR "OpenSSL too old" )
endif ( )
include_directories ( ${ OPENSSL_INCLUDE_DIR } )
add_definitions ( -DHAVE_OPENSSL_1_1 )
# target_link_libraries ( n2n crypto )
target_link_libraries ( n2n ${ OPENSSL_LIBRARIES } )
endif ( N2N_OPTION_USE_OPENSSL )
endif ( N2N_OPTION_USE_OPENSSL )
if ( N2N_OPTION_USE_ZSTD )
if ( N2N_OPTION_USE_ZSTD )
find_library ( LIBZSTD libztd )
if ( NOT LIBZSTD )
MESSAGE ( FATAL_ERROR "libzstd not found." )
endif ( NOT LIBZSTD )
MESSAGE ( INFO "Using libztd." )
add_definitions ( -DN2N_HAVE_ZSTD )
add_definitions ( -DN2N_HAVE_ZSTD )
target_link_libraries ( n2n zstd )
endif ( N2N_OPTION_USE_ZSTD )
endif ( N2N_OPTION_USE_ZSTD )
if ( N2N_OPTION_USE_PCAPLIB )
find_library ( PCAP_LIB pcap )
if ( NOT PCAP_LIB )
MESSAGE ( FATAL_ERROR "libpcap not found." )
endif ( NOT PCAP_LIB )
# T O D O
# - t h i s i s d i f f e r e n t t o t h e c o n f i g u r e . a c l o g i c
check_function_exists ( pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE )
IF ( NOT HAVE_PCAP_IMMEDIATE_MODE )
MESSAGE ( FATAL_ERROR "libpcap not support pcap_set_immediate_modei()" )
ENDIF ( HAVE_PCAP_IMMEDIATE_MODE )
MESSAGE ( INFO "Using libpcap." )
ADD_DEFINITIONS ( "-DHAVE_PCAP_IMMEDIATE_MODE" )
add_executable ( n2n-decode tools/n2n-decode.c )
target_link_libraries ( n2n-decode n2n pcap )
install ( TARGETS n2n-decode RUNTIME DESTINATION bin )
# T O D O :
# - T h i s v a r i a b l e i s a l s o s e t e l s e w h e r e , I d o n t t h i n k i t w o r k s t h i s w a y
set ( CMAKE_REQUIRED_LIBRARIES ${ PCAP_LIB } )
endif ( N2N_OPTION_USE_PCAPLIB )
if ( N2N_OPTION_USE_CAPLIB )
# L i n u x C a p a b i l i t i e s
find_library ( CAP_LIB cap )
if ( NOT CAP_LIB )
MESSAGE ( FATAL_ERROR "libcap not found." )
endif ( NOT CAP_LIB )
MESSAGE ( INFO "Using libpcap." )
ADD_DEFINITIONS ( "-DHAVE_LIBCAP" )
target_link_libraries ( edge cap.a )
# T O D O :
# - T h i s v a r i a b l e i s a l s o s e t e l s e w h e r e , I d o n t t h i n k i t w o r k s t h i s w a y
set ( CMAKE_REQUIRED_LIBRARIES ${ CAP_LIB } )
endif ( N2N_OPTION_USE_CAPLIB )
if ( N2N_OPTION_USE_PORTMAPPING )
if ( N2N_OPTION_USE_PORTMAPPING )
ADD_DEFINITIONS ( "-DHAVE_MINIUPNP" )
ADD_DEFINITIONS ( "-DHAVE_MINIUPNP" )
include_directories ( ${ THIRD_PARTY_DIR } /miniupnp/miniupnpc/include )
include_directories ( ${ THIRD_PARTY_DIR } /miniupnp/miniupnpc/include )
include_directories ( ${ PROJECT_BINARY_DIR } /lib_miniupnpc )
add_subdirectory ( ${ THIRD_PARTY_DIR } /miniupnp/miniupnpc lib_miniupnpc )
link_directories ( ${ PROJECT_BINARY_DIR } /lib_miniupnpc )
target_link_libraries ( n2n libminiupnpc-static )
ADD_DEFINITIONS ( "-DHAVE_NATPMP" )
ADD_DEFINITIONS ( "-DHAVE_NATPMP" )
include_directories ( ${ THIRD_PARTY_DIR } /libnatpmp )
include_directories ( ${ THIRD_PARTY_DIR } /libnatpmp )
add_subdirectory ( ${ THIRD_PARTY_DIR } /libnatpmp libnatpmp )
link_directories ( ${ PROJECT_BINARY_DIR } /libnatpmp )
target_link_libraries ( n2n natpmp )
# T O D O :
# - t h i s i s t h e o d d o n e o u t , i s i t n e e d e d ?
include_directories ( ${ PROJECT_BINARY_DIR } /lib_miniupnpc )
endif ( N2N_OPTION_USE_PORTMAPPING )
endif ( N2N_OPTION_USE_PORTMAPPING )
if ( NOT DEFINED CMAKE_BUILD_TYPE )
if ( NOT DEFINED CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE None )
set ( CMAKE_BUILD_TYPE None )
endif ( NOT DEFINED CMAKE_BUILD_TYPE )
endif ( NOT DEFINED CMAKE_BUILD_TYPE )
@ -154,28 +208,6 @@ add_library(n2n STATIC
s r c / n 2 n _ p o r t _ m a p p i n g . c )
s r c / n 2 n _ p o r t _ m a p p i n g . c )
if ( N2N_OPTION_USE_PTHREAD )
target_link_libraries ( n2n pthread )
endif ( N2N_OPTION_USE_PTHREAD )
if ( N2N_OPTION_USE_OPENSSL )
# target_link_libraries ( n2n crypto )
target_link_libraries ( n2n ${ OPENSSL_LIBRARIES } )
endif ( N2N_OPTION_USE_OPENSSL )
if ( N2N_OPTION_USE_ZSTD )
target_link_libraries ( n2n zstd )
endif ( N2N_OPTION_USE_ZSTD )
if ( N2N_OPTION_USE_PORTMAPPING )
add_subdirectory ( ${ THIRD_PARTY_DIR } /miniupnp/miniupnpc lib_miniupnpc )
link_directories ( ${ PROJECT_BINARY_DIR } /lib_miniupnpc )
target_link_libraries ( n2n libminiupnpc-static )
add_subdirectory ( ${ THIRD_PARTY_DIR } /libnatpmp libnatpmp )
link_directories ( ${ PROJECT_BINARY_DIR } /libnatpmp )
target_link_libraries ( n2n natpmp )
endif ( N2N_OPTION_USE_PORTMAPPING )
if ( DEFINED WIN32 )
if ( DEFINED WIN32 )
add_library ( edge_utils_win32 src/edge_utils_win32.c )
add_library ( edge_utils_win32 src/edge_utils_win32.c )
add_subdirectory ( win32 )
add_subdirectory ( win32 )
@ -197,16 +229,6 @@ target_link_libraries(example_edge_embed n2n)
add_executable ( example_sn_embed src/example_sn_embed.c )
add_executable ( example_sn_embed src/example_sn_embed.c )
target_link_libraries ( example_sn_embed n2n )
target_link_libraries ( example_sn_embed n2n )
if ( N2N_OPTION_USE_PCAPLIB AND ( NOT DEFINED WIN32 ) )
# L i n u x C a p a b i l i t i e s
find_library ( CAP_LIB cap )
if ( CAP_LIB )
target_link_libraries ( edge cap.a )
set ( CMAKE_REQUIRED_LIBRARIES ${ CAP_LIB } )
ADD_DEFINITIONS ( "-DHAVE_LIBCAP" )
endif ( )
endif ( N2N_OPTION_USE_PCAPLIB AND ( NOT DEFINED WIN32 ) )
install ( TARGETS edge supernode
install ( TARGETS edge supernode
R U N T I M E D E S T I N A T I O N s b i n
R U N T I M E D E S T I N A T I O N s b i n
L I B R A R Y D E S T I N A T I O N l i b
L I B R A R Y D E S T I N A T I O N l i b
@ -233,21 +255,6 @@ target_link_libraries(tests-transform n2n)
add_executable ( tests-wire tools/tests-wire.c )
add_executable ( tests-wire tools/tests-wire.c )
target_link_libraries ( tests-wire n2n )
target_link_libraries ( tests-wire n2n )
if ( N2N_OPTION_USE_PCAPLIB )
find_library ( PCAP_LIB pcap )
if ( PCAP_LIB )
add_executable ( n2n-decode tools/n2n-decode.c )
target_link_libraries ( n2n-decode n2n pcap )
install ( TARGETS n2n-decode RUNTIME DESTINATION bin )
set ( CMAKE_REQUIRED_LIBRARIES ${ PCAP_LIB } )
check_function_exists ( pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE )
IF ( HAVE_PCAP_IMMEDIATE_MODE )
ADD_DEFINITIONS ( "-DHAVE_PCAP_IMMEDIATE_MODE" )
ENDIF ( HAVE_PCAP_IMMEDIATE_MODE )
endif ( PCAP_LIB )
endif ( N2N_OPTION_USE_PCAPLIB )
install ( TARGETS n2n-benchmark RUNTIME DESTINATION bin )
install ( TARGETS n2n-benchmark RUNTIME DESTINATION bin )
# D o c u m e n t a t i o n
# D o c u m e n t a t i o n