@ -1,10 +1,24 @@
project ( n2n )
project ( n2n )
cmake_minimum_required ( VERSION 2.6 )
cmake_minimum_required ( VERSION 2.6 )
include ( CheckFunctionExists )
include ( CheckFunctionExists )
SET ( CMAKE_VERBOSE_MAKEFILE ON )
# N 2 n i n f o r m a t i o n
# N 2 n i n f o r m a t i o n
set ( N2N_VERSION 2.5.1 )
execute_process (
C O M M A N D g i t r e v - l i s t - - c o u n t H E A D
W O R K I N G _ D I R E C T O R Y $ { P R O J E C T _ S O U R C E _ D I R }
O U T P U T _ V A R I A B L E G I T _ R E V
)
execute_process (
C O M M A N D g i t r e v - p a r s e - - s h o r t H E A D
W O R K I N G _ D I R E C T O R Y $ { P R O J E C T _ S O U R C E _ D I R }
O U T P U T _ V A R I A B L E G I T _ I D
)
string ( REGEX REPLACE "\n$" "" GIT_REV "${GIT_REV}" )
string ( REGEX REPLACE "\n$" "" GIT_ID "${GIT_ID}" )
set ( N2N_VERSION "2.7.0.r${GIT_REV}.${GIT_ID}" )
set ( N2N_OSNAME ${ CMAKE_SYSTEM } )
set ( N2N_OSNAME ${ CMAKE_SYSTEM } )
MESSAGE ( STATUS "Build from git rev: ${N2N_VERSION}" )
# 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_AES "USE AES" ON )
OPTION ( N2N_OPTION_AES "USE AES" ON )
@ -22,8 +36,11 @@ add_definitions(-DGIT_RELEASE="" -DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OS
add_definitions ( -DN2N_VERSION= "${N2N_VERSION}" -DN2N_OSNAME= "${N2N_OSNAME}" )
add_definitions ( -DN2N_VERSION= "${N2N_VERSION}" -DN2N_OSNAME= "${N2N_OSNAME}" )
if ( N2N_OPTION_AES )
if ( N2N_OPTION_AES )
find_package ( OpenSSL REQUIRED )
if ( NOT DEFINED WIN32 )
add_definitions ( -DN2N_HAVE_AES )
find_package ( OpenSSL REQUIRED )
include_directories ( ${ OPENSSL_INCLUDE_DIR } )
endif ( NOT DEFINED WIN32 )
add_definitions ( -DN2N_HAVE_AES )
endif ( N2N_OPTION_AES )
endif ( N2N_OPTION_AES )
if ( NOT DEFINED CMAKE_BUILD_TYPE )
if ( NOT DEFINED CMAKE_BUILD_TYPE )
@ -42,7 +59,10 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g")
# R e l e a s e
# R e l e a s e
set ( CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" )
set ( CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" )
set ( CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" )
set ( CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" )
endif ( )
endif ( DEFINED UNIX )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static" )
# # D E B U G F O R C M A K E
# # D E B U G F O R C M A K E
# message ( ${ N2N_VERSION } )
# message ( ${ N2N_VERSION } )
@ -51,51 +71,67 @@ endif()
# message ( ${ N2N_OPTION_AES } )
# message ( ${ N2N_OPTION_AES } )
# # D E B U G F O R C M A K E
# # D E B U G F O R C M A K E
INCLUDE_DIRECTORIES ( . )
INCLUDE_DIRECTORIES ( include )
if ( DEFINED WIN32 )
INCLUDE_DIRECTORIES ( win32 )
INCLUDE_DIRECTORIES ( "D:/Program Files/MinGW/opt/include/" "D:/Program Files/MinGW/x86_64-w64-mingw32/include/" )
LINK_DIRECTORIES ( "D:/Program Files/MinGW/opt/lib/" "D:/Program Files/MinGW/x86_64-w64-mingw32/lib/" )
endif ( DEFINED WIN32 )
# A d d S H A R E D t o b u i l d D L L
# A d d S H A R E D t o b u i l d D L L
add_library ( n2n n2n.c
# aux_source_directory ( ./src N2N_DIR_SRCS )
e d g e _ u t i l s . c
# add_library ( n2n STATIC ${ N2N_DIR_SRCS } )
s n _ u t i l s . c
add_library ( n2n
w i r e . c
s r c / n 2 n . c
m i n i l z o . c
s r c / e d g e _ u t i l s . c
t w o f i s h . c
s r c / s n _ u t i l s . c
t r a n s f o r m _ n u l l . c
s r c / w i r e . c
t r a n s f o r m _ t f . c
s r c / m i n i l z o . c
t r a n s f o r m _ a e s . c
s r c / t w o f i s h . c
t r a n s f o r m _ c c 2 0 . c
s r c / t r a n s f o r m _ n u l l . c
t r a n s f o r m _ s p e c k . c
s r c / t r a n s f o r m _ t f . c
s p e c k . c
s r c / t r a n s f o r m _ a e s . c
r a n d o m _ n u m b e r s . c
s r c / t r a n s f o r m _ c c 2 0 . c
p e a r s o n . c
s r c / t r a n s f o r m _ s p e c k . c
h e a d e r _ e n c r y p t i o n . c
s r c / s p e c k . c
t u n t a p _ f r e e b s d . c
s r c / r a n d o m _ n u m b e r s . c
t u n t a p _ n e t b s d . c
s r c / p e a r s o n . c
t u n t a p _ l i n u x . c
s r c / h e a d e r _ e n c r y p t i o n . c
t u n t a p _ o s x . c
s r c / t u n t a p _ f r e e b s d . c
s r c / t u n t a p _ n e t b s d . c
s r c / t u n t a p _ l i n u x . c
s r c / t u n t a p _ o s x . c
)
)
if ( DEFINED WIN32 )
if ( DEFINED WIN32 )
add_subdirectory ( win32 )
add_library ( edge_utils_win32 src/edge_utils_win32.c )
target_link_libraries ( n2n n2n_win32 )
add_subdirectory ( win32 )
target_link_libraries ( n2n edge_utils_win32 n2n_win32 )
endif ( DEFINED WIN32 )
endif ( DEFINED WIN32 )
if ( N2N_OPTION_AES )
if ( N2N_OPTION_AES )
target_link_libraries ( n2n ${ OPENSSL_LIBRARIES } )
if ( DEFINED WIN32 )
include_directories ( ${ OPENSSL_INCLUDE_DIR } )
target_link_libraries ( n2n crypto )
else ( )
target_link_libraries ( n2n ${ OPENSSL_LIBRARIES } )
endif ( DEFINED WIN32 )
endif ( N2N_OPTION_AES )
endif ( N2N_OPTION_AES )
add_executable ( edge edge.c )
add_executable ( edge src/ edge.c)
target_link_libraries ( edge n2n )
target_link_libraries ( edge n2n )
add_executable ( supernode sn.c )
add_executable ( supernode src/s n.c )
target_link_libraries ( supernode n2n )
target_link_libraries ( supernode n2n )
add_executable ( example_edge_embed_quick_edge_init example_edge_embed_quick_edge_init.c )
add_executable ( example_edge_embed_quick_edge_init src/ example_edge_embed_quick_edge_init.c)
target_link_libraries ( example_edge_embed_quick_edge_init n2n )
target_link_libraries ( example_edge_embed_quick_edge_init n2n )
add_executable ( example_edge_embed example_edge_embed.c )
add_executable ( example_edge_embed src/ example_edge_embed.c)
target_link_libraries ( example_edge_embed n2n )
target_link_libraries ( example_edge_embed n2n )
add_executable ( example_sn_embed 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 ( NOT DEFINED WIN32 )
if ( NOT DEFINED WIN32 )
@ -115,8 +151,6 @@ install(TARGETS edge supernode
)
)
# T o o l s
# T o o l s
include_directories ( . )
add_executable ( n2n-benchmark tools/benchmark.c )
add_executable ( n2n-benchmark tools/benchmark.c )
target_link_libraries ( n2n-benchmark n2n ${ OPENSSL_LIBRARIES } )
target_link_libraries ( n2n-benchmark n2n ${ OPENSSL_LIBRARIES } )
@ -130,8 +164,8 @@ if(PCAP_LIB)
check_function_exists ( pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE )
check_function_exists ( pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE )
IF ( HAVE_PCAP_IMMEDIATE_MODE )
IF ( HAVE_PCAP_IMMEDIATE_MODE )
ADD_DEFINITIONS ( "-DHAVE_PCAP_IMMEDIATE_MODE" )
ADD_DEFINITIONS ( "-DHAVE_PCAP_IMMEDIATE_MODE" )
ENDIF ( )
ENDIF ( HAVE_PCAP_IMMEDIATE_MODE )
endif ( )
endif ( PCAP_LIB )
install ( TARGETS n2n-benchmark RUNTIME DESTINATION bin )
install ( TARGETS n2n-benchmark RUNTIME DESTINATION bin )