@ -9,27 +9,27 @@ set(PROJECT_NAME lokinet)
project ( ${ PROJECT_NAME } C CXX )
# C o r e o p t i o n s
option ( USE_AVX2 "enable avx2 code" )
option ( USE_NETNS "enable networking namespace support. Linux only" )
option ( AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" )
option ( NATIVE_BUILD "optimise for host system and FPU, may not be portable" )
option ( EMBEDDED_CFG "optimise for older hardware or embedded systems" )
option ( USE_AVX2 "enable avx2 code" OFF )
option ( USE_NETNS "enable networking namespace support. Linux only" OFF )
option ( AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" OFF )
option ( NATIVE_BUILD "optimise for host system and FPU, may not be portable" ON )
option ( EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF )
if ( NOT MSVC )
option ( STATIC_LINK "link statically against dependencies" OFF )
option ( STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads" )
endif ( )
option ( NON_PC_TARGET "non-pc target build: iphone, andriod, embedded non-i386 SBC, etc" )
option ( SHADOW "use shadow testing framework. linux only" )
option ( XSAN "use sanitiser, if your system has it" )
option ( JEMALLOC "use jemalloc. Not required on BSD" )
option ( DEBIAN "build for debian" )
option ( TESTNET "testnet build" )
option ( WITH_SHARED "build shared library" )
option ( WITH_COVERAGE "generate coverage data" )
option ( STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads" OFF )
endif ( )
option ( SHADOW "use shadow testing framework. linux only" OFF )
option ( XSAN "use sanitiser, if your system has it" OFF )
option ( JEMALLOC "use jemalloc. Not required on BSD" OFF )
option ( DEBIAN "build for debian" OFF )
option ( TESTNET "testnet build" OFF )
option ( WITH_SHARED "build shared library" OFF )
option ( WITH_COVERAGE "generate coverage data" OFF )
option ( USE_SHELLHOOKS "enable shell hooks on compile time (dangerous)" OFF )
option ( WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF )
option ( TRACY_ROOT "include tracy profiler source" )
option ( TRACY_ROOT "include tracy profiler source" OFF )
option ( VENDOR_LIBSODIUM "use vendored libsodium" OFF )
option ( WITH_TESTS "build unit tests" ON )
include ( cmake/target_link_libraries_system.cmake )
include ( cmake/add_import_library.cmake )
@ -46,6 +46,17 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include ( MacroEnsureOutOfSourceBuild )
macro_ensure_out_of_source_build ( "${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'." )
# t r y d e t e c t i n g t h e t a r g e t a r c h a n d s e t t h e f l a g s n e e d e d h e r e
if ( NOT WIN32 )
include ( TargetArch )
target_architecture ( COMPILE_ARCH )
if ( COMPILE_ARCH MATCHES i386 OR COMPILE_ARCH MATCHES x86_64 )
set ( NON_PC_TARGET OFF )
else ( )
set ( NON_PC_TARGET ON )
endif ( )
endif ( )
include ( cmake/basic_definitions.cmake )
if ( MSVC_VERSION )
@ -146,12 +157,12 @@ endif(WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
if ( DEBIAN )
add_definitions ( -DDEBIAN )
elseif ( NOT ANDROID AND NOT NON_PC_TARGET )
if ( NOT USE_AVX2 )
elseif ( WIN32 )
if ( USE_AVX2 )
set ( CRYPTO_FLAGS -march=haswell -mtune=native -mfpmath=sse )
else ( )
# P u b l i c b i n a r y r e l e a s e s
set ( CRYPTO_FLAGS -march=nocona -mtune=core2 -mfpmath=sse )
else ( )
set ( CRYPTO_FLAGS -march=haswell -mtune=native -mfpmath=sse )
endif ( )
endif ( )
@ -162,8 +173,8 @@ if(AMD_RYZEN_HACK AND USE_AVX2)
endif ( AMD_RYZEN_HACK AND USE_AVX2 )
if ( NATIVE_BUILD )
message ( WARNING "May fail at runtime if the floating-point unit on the target system does not implement required features, some platforms will check this for you" )
set ( CRYPTO_FLAGS -march=native -m fpmath=sse -m tune=native)
# message ( WARNING "May fail at runtime if the floating-point unit on the target system does not implement required features, some platforms will check this for you" )
set ( CRYPTO_FLAGS -march=native -m tune=native)
endif ( )
if ( EMBEDDED_CFG )
@ -236,10 +247,14 @@ add_subdirectory(llarp)
add_subdirectory ( libabyss )
add_subdirectory ( daemon )
enable_testing ( )
if ( WITH_TESTS )
enable_testing ( )
endif ( )
if ( NOT SHADOW )
if ( WITH_TESTS )
add_subdirectory ( test )
endif ( )
if ( ANDROID )
add_subdirectory ( jni )
endif ( ANDROID )