Skip to content

Commit

Permalink
Merge pull request #9 from Beldex-Coin/dev
Browse files Browse the repository at this point in the history
From dev
  • Loading branch information
sanada08 authored Aug 22, 2022
2 parents 7c94f84 + 2c5fa2a commit 56b1846
Show file tree
Hide file tree
Showing 229 changed files with 4,518 additions and 2,698 deletions.
82 changes: 39 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Has to be set before `project()`, and ignored on non-macos:
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)")

set(LANGS C CXX)
if(APPLE)
set(LANGS ${LANGS} OBJC Swift)
endif()

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
foreach(lang C CXX)
foreach(lang ${LANGS})
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache")
message(STATUS "Enabling ccache for ${lang}")
set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "")
endif()
endforeach()
endif()


project(belnet
VERSION 0.9.5
VERSION 0.9.6
DESCRIPTION "belnet - IP packet onion router"
LANGUAGES C CXX)
LANGUAGES ${LANGS})

if(APPLE)
# Apple build number: must be incremented to submit a new build for the same belnet version,
# should be reset to 0 when the belnet version increments.
set(BELNET_APPLE_BUILD 0)
endif()

set(RELEASE_MOTTO "A Series of Tubes" CACHE STRING "Release motto")

Expand All @@ -32,7 +44,6 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")


# Core options
option(USE_AVX2 "enable avx2 code" OFF)
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
Expand All @@ -41,7 +52,7 @@ option(EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF)
option(BUILD_LIBBELNET "build libbelnet.so" ON)
option(SHADOW "use shadow testing framework. linux only" OFF)
option(XSAN "use sanitiser, if your system has it (requires -DCMAKE_BUILD_TYPE=Debug)" OFF)
option(WITH_JEMALLOC "use jemalloc as allocator" OFF)
option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
option(TESTNET "testnet build" OFF)
option(WITH_COVERAGE "generate coverage data" OFF)
option(USE_SHELLHOOKS "enable shell hooks on compile time (dangerous)" OFF)
Expand Down Expand Up @@ -94,14 +105,6 @@ endif()

add_definitions(-D${CMAKE_SYSTEM_NAME})

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()

include(cmake/solaris.cmake)
include(cmake/win32.cmake)

Expand Down Expand Up @@ -168,7 +171,7 @@ if(NOT TARGET sodium)
export(TARGETS sodium NAMESPACE sodium:: FILE sodium-exports.cmake)
endif()

option(FORCE_OXENMQ_SUBMODULE "force using oxenmq submodule" OFF)
option(FORCE_OXENMQ_SUBMODULE "force using oxenmq submodule" ON)
if(NOT FORCE_OXENMQ_SUBMODULE)
pkg_check_modules(OXENMQ liboxenmq>=1.2.4)
endif()
Expand All @@ -184,8 +187,12 @@ else()
endif()


# this is messing with release builds
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0)
if(NOT APPLE)
add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -Wall -Wextra -Wno-unknown-pragmas -Wno-unused-function -Wno-deprecated-declarations -Werror=vla)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unknown-warning-option)
endif()
endif()

if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux" AND SHADOW)
message( FATAL_ERROR "shadow-framework is Linux only" )
Expand Down Expand Up @@ -213,36 +220,27 @@ if(TRACY_ROOT)
endif()


if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unknown-warning-option)
endif()

if (NOT MSVC_VERSION)
add_compile_options(-Wall -Wextra -Wno-unknown-pragmas)
# vla are evil
add_compile_options(-Werror=vla)
add_compile_options(-Wno-unused-function -Wno-deprecated-declarations)
endif()

include(cmake/coverage.cmake)

# these vars are set by the cmake toolchain spec
if (WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
include(cmake/cross_compile.cmake)
endif()

if(NATIVE_BUILD)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le)
add_compile_options(-mcpu=native -mtune=native)
else()
add_compile_options(-march=native -mtune=native)
endif()
elseif(NOT NON_PC_TARGET)
if (USE_AVX2)
add_compile_options(-march=haswell -mtune=haswell -mfpmath=sse)
else()
# Public binary releases
add_compile_options(-march=nocona -mtune=haswell -mfpmath=sse)
if(NOT APPLE)
if(NATIVE_BUILD)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le)
add_compile_options(-mcpu=native -mtune=native)
else()
add_compile_options(-march=native -mtune=native)
endif()
elseif(NOT NON_PC_TARGET)
if (USE_AVX2)
add_compile_options(-march=haswell -mtune=haswell -mfpmath=sse)
else()
# Public binary releases
add_compile_options(-march=nocona -mtune=haswell -mfpmath=sse)
endif()
endif()
endif()

Expand Down Expand Up @@ -302,7 +300,6 @@ endif()
add_subdirectory(external)
include_directories(SYSTEM external/sqlite_orm/include)

option(USE_JEMALLOC "Link to jemalloc for memory allocations, if found" ON)
if(USE_JEMALLOC AND NOT STATIC_LINK)
pkg_check_modules(JEMALLOC jemalloc IMPORTED_TARGET)
if(JEMALLOC_FOUND)
Expand Down Expand Up @@ -332,12 +329,11 @@ endif()
add_subdirectory(crypto)
add_subdirectory(llarp)
add_subdirectory(daemon)

if(WITH_HIVE)
add_subdirectory(pybind)
endif()



if (NOT SHADOW)
if(WITH_TESTS OR WITH_HIVE)
add_subdirectory(test)
Expand All @@ -361,6 +357,6 @@ if(NOT TARGET uninstall)
endif()


if(BUILD_PACKAGE)
if(BUILD_PACKAGE AND NOT APPLE)
include(cmake/installer.cmake)
endif()
9 changes: 5 additions & 4 deletions cmake/StaticBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

set(LOCAL_MIRROR "" CACHE STRING "local mirror path/URL for lib downloads")

set(OPENSSL_VERSION 1.1.1k CACHE STRING "openssl version")
set(OPENSSL_VERSION 1.1.1l CACHE STRING "openssl version")
set(OPENSSL_MIRROR ${LOCAL_MIRROR} https://www.openssl.org/source CACHE STRING "openssl download mirror(s)")
set(OPENSSL_SOURCE openssl-${OPENSSL_VERSION}.tar.gz)
set(OPENSSL_HASH SHA256=892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
set(OPENSSL_HASH SHA256=0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
CACHE STRING "openssl source hash")

set(EXPAT_VERSION 2.3.0 CACHE STRING "expat version")
Expand All @@ -19,10 +19,10 @@ set(EXPAT_SOURCE expat-${EXPAT_VERSION}.tar.xz)
set(EXPAT_HASH SHA512=dde8a9a094b18d795a0e86ca4aa68488b352dc67019e0d669e8b910ed149628de4c2a49bc3a5b832f624319336a01f9e4debe03433a43e1c420f36356d886820
CACHE STRING "expat source hash")

set(UNBOUND_VERSION 1.13.1 CACHE STRING "unbound version")
set(UNBOUND_VERSION 1.13.2 CACHE STRING "unbound version")
set(UNBOUND_MIRROR ${LOCAL_MIRROR} https://nlnetlabs.nl/downloads/unbound CACHE STRING "unbound download mirror(s)")
set(UNBOUND_SOURCE unbound-${UNBOUND_VERSION}.tar.gz)
set(UNBOUND_HASH SHA256=8504d97b8fc5bd897345c95d116e0ee0ddf8c8ff99590ab2b4bd13278c9f50b8
set(UNBOUND_HASH SHA256=0a13b547f3b92a026b5ebd0423f54c991e5718037fd9f72445817f6a040e1a83
CACHE STRING "unbound source hash")

set(SQLITE3_VERSION 3350500 CACHE STRING "sqlite3 version")
Expand Down Expand Up @@ -388,6 +388,7 @@ foreach(curl_arch ${curl_arches})
--disable-progress-meter --without-brotli --with-zlib=${DEPS_DESTDIR} ${curl_ssl_opts}
--without-libmetalink --without-librtmp --disable-versioned-symbols --enable-hidden-symbols
--without-zsh-functions-dir --without-fish-functions-dir
--without-nghttp3 --without-zstd
"CC=${deps_cc}" "CFLAGS=${deps_noarch_CFLAGS}${cflags_extra}" ${curl_extra}
BUILD_COMMAND true
INSTALL_COMMAND ${_make} -C lib install && ${_make} -C include install
Expand Down
3 changes: 1 addition & 2 deletions cmake/add_log_tag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ function(add_log_tag target)
get_target_property(TARGET_SRCS ${target} SOURCES)
foreach(F ${TARGET_SRCS})
get_filename_component(fpath "${F}" ABSOLUTE)
string(REPLACE "${PROJECT_SOURCE_DIR}/" "" logtag "${fpath}")
set_property(SOURCE ${F} APPEND PROPERTY COMPILE_DEFINITIONS LOG_TAG=\"${logtag}\")
set_property(SOURCE ${F} APPEND PROPERTY COMPILE_DEFINITIONS SOURCE_ROOT=\"${PROJECT_SOURCE_DIR}\")
endforeach()
endfunction()
9 changes: 3 additions & 6 deletions cmake/installer.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
set(CPACK_PACKAGE_VENDOR "belnet.org")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://belnet.org/")
set(CPACK_PACKAGE_VENDOR "belnet.beldex.io")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://belnet.beldex.io/")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/contrib/readme-installer.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")

if(WIN32)
include(cmake/win32_installer_deps.cmake)
endif()

if(APPLE)
include(cmake/macos_installer_deps.cmake)
endif()


# This must always be last!
include(CPack)

98 changes: 49 additions & 49 deletions cmake/libatomic.cmake
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
if (EMBEDDED_CFG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m32 -march=i486")
elseif(MSVC OR MSVC_VERSION)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32 -std:c++14")
else()
# CMAKE_CXX_STANDARD does not propagate to cmake compile tests
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14")
endif()
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction()

function(link_libatomic)
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)

if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
message(STATUS "Have working 64bit atomics")
return()
endif()

if (NOT MSVC AND NOT MSVC_VERSION)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if (HAVE_CXX_LIBATOMICS64)
message(STATUS "Have 64bit atomics via library")
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (HAVE_CXX_ATOMICS64_WITH_LIB)
message(STATUS "Can link with libatomic")
link_libraries(-latomic)
return()
endif()
endif()
endif()
if (MSVC OR MSVC_VERSION)
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What does MSVC do to inline atomics?)")
else()
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
endif()
endfunction()
function(check_working_cxx_atomics64 varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
if (EMBEDDED_CFG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -m32 -march=i486")
elseif(MSVC OR MSVC_VERSION)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32 -std:c++14")
else()
# CMAKE_CXX_STANDARD does not propagate to cmake compile tests
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++14")
endif()
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
std::atomic<uint64_t> x (0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
return 0;
}
" ${varname})
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endfunction()

function(link_libatomic)
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)

if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
message(STATUS "Have working 64bit atomics")
return()
endif()

if (NOT MSVC AND NOT MSVC_VERSION)
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
if (HAVE_CXX_LIBATOMICS64)
message(STATUS "Have 64bit atomics via library")
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
if (HAVE_CXX_ATOMICS64_WITH_LIB)
message(STATUS "Can link with libatomic")
link_libraries(-latomic)
return()
endif()
endif()
endif()
if (MSVC OR MSVC_VERSION)
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What does MSVC do to inline atomics?)")
else()
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
endif()
endfunction()
Loading

0 comments on commit 56b1846

Please sign in to comment.