@ -2,7 +2,7 @@
cmake_minimum_required ( VERSION 3.6.0 )
set ( PROJECT_NAME lokinet )
project ( ${ PROJECT_NAME } C CXX ASM )
project ( ${ PROJECT_NAME } C CXX )
# C o r e o p t i o n s
option ( USE_AVX2 "enable avx2 code" )
@ -28,15 +28,23 @@ if(CCACHE_PROGRAM)
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}" )
endif ( )
if ( MSVC_VERSION )
enable_language ( ASM_MASM )
list ( APPEND CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS s )
add_definitions ( /D_WIN32_WINNT=0x0600 /DNOMINMAX /DSODIUM_STATIC )
else ( )
enable_language ( ASM )
endif ( MSVC_VERSION )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
# c h e c k i f w e h a v e the ( saner ) e m u l a t i o n o f e p o l l h e r e
# i t ' s b a s i c a l l y l i n u x e p o l l b u t w i t h a s a n e m e t h o d o f
# d e a l i n g w i t h c l o s e d f i l e h a n d l e s t h a t s t i l l e x i s t i n t h e
# e p o l l s e t
#
# N o t e t h a t t h e z o m b i e o f O r a c l e S o l a r i s 2 . 1 1 . x w i l l N O T h a v e
# t h i s , t h e h e a d e r c h e c k i s t h e o n l y m e t h o d w e h a v e t o d i s t i n g u i s h
# t h e m . - r i c k t h e s v r 4 g u y
# c h e c k i f w e h a v e the ( saner ) e m u l a t i o n o f e p o l l h e r e
# i t ' s b a s i c a l l y l i n u x e p o l l b u t w i t h a s a n e m e t h o d o f
# d e a l i n g w i t h c l o s e d f i l e h a n d l e s t h a t s t i l l e x i s t i n t h e
# e p o l l s e t
#
# N o t e t h a t t h e z o m b i e o f O r a c l e S o l a r i s 2 . 1 1 . x w i l l N O T h a v e
# t h i s , t h e h e a d e r c h e c k i s t h e o n l y m e t h o d w e h a v e t o d i s t i n g u i s h
# t h e m . - r i c k t h e s v r 4 g u y
set ( SOLARIS ON )
option ( USE_POLL "Revert to using poll(2) event loop (useful if targeting Oracle Solaris)" OFF )
set ( CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lsocket -lnsl" )
@ -72,6 +80,7 @@ if (WIN32 AND NOT STATIC_LINK_RUNTIME)
message ( "for release builds, turn on STATIC_LINK_RUNTIME in cmake options" )
endif ( WIN32 AND NOT STATIC_LINK_RUNTIME )
add_subdirectory ( vendor/cxxopts )
add_subdirectory ( vendor/nlohmann )
# s t i l l n e e d t h e h e a d e r s u n c o n d i t i o n a l l y
@ -90,11 +99,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options ( -Wno-unknown-warning-option )
endif ( )
add_compile_options ( -Wall -Wextra -Wno-unknown-pragmas )
# v l a a r e e v i l
add_compile_options ( -Wvla )
add_compile_options ( $< $<COMPILE_LANGUAGE:CXX > :-fpermissive> )
add_compile_options ( -Wno-unused-function -Wno-deprecated-declarations -Wno-unknown-pragmas )
if ( NOT MSVC_VERSION )
add_compile_options ( -Wall -Wextra -Wno-unknown-pragmas )
# v l a a r e e v i l
add_compile_options ( -Wvla )
add_compile_options ( $< $<COMPILE_LANGUAGE:CXX > :-fpermissive> )
add_compile_options ( -Wno-unused-function -Wno-deprecated-declarations -Wno-unknown-pragmas )
endif ( )
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
add_compile_options ( -Wthread-safety )
@ -127,15 +138,15 @@ if (WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
endif ( )
endif ( WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE )
if ( WIN32 )
if ( WIN32 AND NOT MSVC_VERSION )
add_compile_options ( $< $<COMPILE_LANGUAGE:C > :-Wno-bad-function-cast> )
add_compile_options ( $< $<COMPILE_LANGUAGE:C > :-Wno-cast-function-type> )
# u n l i k e u n i x w h e r e y o u g e t a * s i n g l e * c o m p i l e r I D s t r i n g i n . c o m m e n t
# G N U l d s e e s f i t t o m e r g e * a l l * t h e . i d e n t s e c t i o n s i n o b j e c t f i l e s
# t o . r [ o ] d a t a s e c t i o n o n e a f t e r t h e o t h e r !
# u n l i k e u n i x w h e r e y o u g e t a * s i n g l e * c o m p i l e r I D s t r i n g i n . c o m m e n t
# G N U l d s e e s f i t t o m e r g e * a l l * t h e . i d e n t s e c t i o n s i n o b j e c t f i l e s
# t o . r [ o ] d a t a s e c t i o n o n e a f t e r t h e o t h e r !
add_compile_options ( -fno-ident )
set ( FS_LIB stdc++fs )
endif ( WIN32 )
endif ( )
if ( DEBIAN )
add_definitions ( -DDEBIAN )
@ -184,10 +195,10 @@ if(TESTNET)
add_definitions ( -DTESTNET=1 )
endif ( TESTNET )
if ( NOT DEBIAN )
if ( NOT DEBIAN AND NOT MSVC_VERSION )
set ( OPTIMIZE_FLAGS -O3 )
set ( DEBUG_FLAGS -O0 -g3 )
endif ( NOT DEBIAN )
endif ( )
if ( ASAN )
set ( DEBUG_FLAGS ${ DEBUG_FLAGS } -fsanitize=address -fno-omit-frame-pointer )
@ -232,8 +243,9 @@ endif(NON_PC_TARGET)
add_compile_options ( ${ OPTIMIZE_FLAGS } ${ CRYPTO_FLAGS } )
if ( NOT GIT_VERSION )
exec_program ( "git" ${ CMAKE_CURRENT_SOURCE_DIR } ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_VERSION )
add_definitions ( -DGIT_REV= "${GIT_VERSION}" )
exec_program ( "git" ${ CMAKE_CURRENT_SOURCE_DIR } ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_VERSION_UNSTRIP )
string ( STRIP "${GIT_VERSION_UNSTRIP}" GIT_VERSION )
add_definitions ( "-DGIT_REV=\" ${ GIT_VERSION } \"")
endif ( NOT GIT_VERSION )
if ( RELEASE_MOTTO )
@ -320,7 +332,7 @@ if(UNIX)
elseif ( WIN32 )
get_filename_component ( LIBTUNTAP_IMPL ${ TT_ROOT } /tuntap-windows.c ABSOLUTE )
get_filename_component ( EV_SRC "llarp/ev/ev_win32.cpp" ABSOLUTE )
add_definitions ( -DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x 5 00 -D_WIN32_WINNT=0x 5 00)
add_definitions ( -DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x 06 02 -D_WIN32_WINNT=0x 06 02 )
else ( )
message ( FATAL_ERROR "What operating system _are_ you building on/for?" )
endif ( UNIX )
@ -366,12 +378,17 @@ target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB})
if ( NOT WIN32 )
add_executable ( ${ ABYSS_EXE } ${ ABYSS } /main.cpp )
target_link_libraries ( ${ ABYSS_EXE } PUBLIC ${ ABYSS_LIB } Threads::Threads )
else ( )
else if ( NOT MSVC_VERSION )
add_executable ( ${ ABYSS_EXE } ${ ABYSS } /main.cpp llarp/win32/abyss.rc )
target_link_libraries ( ${ ABYSS_EXE } PUBLIC ${ ABYSS_LIB } ${ STATIC_LIB } ws2_32 )
else ( )
add_executable ( ${ ABYSS_EXE } ${ ABYSS } /main.cpp )
target_link_libraries ( ${ ABYSS_EXE } PUBLIC ${ ABYSS_LIB } ${ STATIC_LIB } ws2_32 )
endif ( NOT WIN32 )
target_include_directories ( ${ ABYSS_LIB } PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include" )
target_include_directories ( ${ ABYSS_EXE } PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${ABYSS}/include" )
# f o r f r e e b s d
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD" )
target_include_directories ( ${ ABYSS_LIB } PUBLIC /usr/local/include )
@ -395,8 +412,10 @@ if(SHADOW)
else ( )
if ( NOT WIN32 )
add_executable ( ${ EXE } ${ EXE_SRC } )
else ( )
else if ( NOT MSVC_VERSION )
add_executable ( ${ EXE } ${ EXE_SRC } llarp/win32/version.rc )
else ( )
add_executable ( ${ EXE } ${ EXE_SRC } )
endif ( NOT WIN32 )
add_log_tag ( ${ EXE } )
@ -424,6 +443,6 @@ endif(SHADOW)
enable_testing ( )
if ( NOT SHADOW )
if ( NOT SHADOW AND NOT MSVC_VERSION )
add_subdirectory ( test )
endif ( )