2018-02-14 14:26:28 +01:00
|
|
|
# This file is part of the Flowee project
|
2021-06-20 22:44:44 +02:00
|
|
|
# Copyright (C) 2018 Tom Zander <tom@flowee.org>
|
2018-02-14 14:26:28 +01:00
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2019-08-11 18:17:22 +02:00
|
|
|
cmake_minimum_required (VERSION 3.13)
|
2018-02-10 14:59:45 +01:00
|
|
|
project (Flowee)
|
|
|
|
|
|
2022-01-14 16:15:53 +01:00
|
|
|
set(COPYRIGHT_YEAR 2022)
|
2018-10-30 10:38:50 +01:00
|
|
|
set(CLIENT_VERSION_MAJOR ${COPYRIGHT_YEAR})
|
2022-05-03 19:48:34 +02:00
|
|
|
set(CLIENT_VERSION_MINOR 4)
|
|
|
|
|
set(CLIENT_VERSION_REVISION 1)
|
2018-10-30 10:38:50 +01:00
|
|
|
set(HUB_SERIES 1)
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------
|
|
|
|
|
|
2020-08-12 22:25:14 +02:00
|
|
|
set(CLIENT_VERSION_IS_RELEASE 1)
|
2021-05-04 18:20:04 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2018-02-10 14:59:45 +01:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/support/cmake)
|
|
|
|
|
|
2018-10-30 10:38:50 +01:00
|
|
|
message(STATUS "Flowee version ${CLIENT_VERSION_MAJOR}-${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_REVISION} ${HUB_SERIES}")
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
set(FLOWEE_GIT_SHA1_STRING "")
|
|
|
|
|
set(FLOWEE_GIT_BRANCH_STRING "")
|
|
|
|
|
|
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
|
|
|
|
get_git_branch(GIT_BRANCH)
|
|
|
|
|
|
2018-02-14 14:56:15 +01:00
|
|
|
if (GIT_SHA1 AND GIT_BRANCH)
|
2018-02-10 14:59:45 +01:00
|
|
|
string(SUBSTRING ${GIT_SHA1} 0 7 GIT_SHA1)
|
|
|
|
|
set(FLOWEE_GIT_SHA1_STRING ${GIT_SHA1})
|
|
|
|
|
set(FLOWEE_GIT_BRANCH_STRING ${GIT_BRANCH})
|
2018-02-14 14:56:15 +01:00
|
|
|
endif ()
|
2018-02-10 14:59:45 +01:00
|
|
|
|
2020-06-05 15:27:34 +02:00
|
|
|
# starting with Qt5.15 we have a lot of deprecation warnings,
|
|
|
|
|
# likely to make porting to Qt6 easier.
|
|
|
|
|
# as long as we require linking to older Qt versions those warnings
|
|
|
|
|
# are clutter. Remove this define when we start porting to Qt6.
|
|
|
|
|
add_definitions(-DQT_NO_DEPRECATED_WARNINGS)
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
############
|
|
|
|
|
#############
|
|
|
|
|
## Options ##
|
|
|
|
|
#############
|
|
|
|
|
############
|
|
|
|
|
|
|
|
|
|
option(dev_setup "Enable developer build, not safe for real-life usage!" OFF)
|
|
|
|
|
option(build_tests "Compile the unit tests" ${dev_setup})
|
|
|
|
|
if (dev_setup)
|
2018-02-15 22:19:32 +01:00
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2019-06-15 13:05:11 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DBCH_LOGCONTEXT -DUSE_UNSAFE_RANDOM -DENABLE_CRASH_CATCHER")
|
2018-02-10 14:59:45 +01:00
|
|
|
message(STATUS "Setting built type to Debug, with unsafe random and other dev options.")
|
2018-02-14 14:56:15 +01:00
|
|
|
elseif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
2018-02-10 14:59:45 +01:00
|
|
|
message(STATUS "Setting build type to 'ReleaseWithDebugInfo' as none was specified.")
|
2018-02-15 22:19:32 +01:00
|
|
|
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
|
2018-07-05 01:14:57 +02:00
|
|
|
# The default build should be free from debugging log-statements.
|
2019-03-04 12:45:39 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE} -DBCH_NO_DEBUG_OUTPUT")
|
2018-02-10 14:59:45 +01:00
|
|
|
# Set the possible values of build type for cmake-gui
|
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
|
|
|
|
|
elseif (NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
|
message(STATUS "Built type is ${CMAKE_BUILD_TYPE}")
|
2018-02-14 14:56:15 +01:00
|
|
|
endif ()
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
# turn off debug logging for release builds
|
2019-03-04 12:45:39 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DBCH_NO_DEBUG_OUTPUT")
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
if (build_tests)
|
|
|
|
|
# add dependency
|
|
|
|
|
set (boost_test_lib "unit_test_framework")
|
2018-02-14 14:56:15 +01:00
|
|
|
endif ()
|
2018-02-10 14:59:45 +01:00
|
|
|
|
2018-02-14 14:56:15 +01:00
|
|
|
option(mark_release "If true, remove the pre-release warning from the app" OFF)
|
|
|
|
|
if (mark_release)
|
2018-02-17 12:18:21 +01:00
|
|
|
if (dev_setup)
|
|
|
|
|
message ("ignoring 'mark-release since you turned on dev-setup, they are incompatible")
|
|
|
|
|
else ()
|
|
|
|
|
set(CLIENT_VERSION_IS_RELEASE 1)
|
|
|
|
|
endif ()
|
2018-02-14 14:56:15 +01:00
|
|
|
endif ()
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
|
2019-08-11 18:17:22 +02:00
|
|
|
# required packages below this
|
|
|
|
|
message ("===== Find required dependencies")
|
2018-02-10 14:59:45 +01:00
|
|
|
|
2019-09-07 19:51:42 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1/")
|
2019-09-07 22:17:04 +02:00
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt")
|
2019-09-07 19:51:42 +02:00
|
|
|
endif()
|
|
|
|
|
|
2018-02-10 14:59:45 +01:00
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
|
message ("Using OpenSSL ${OPENSSL_VERSION}")
|
2019-08-11 18:17:22 +02:00
|
|
|
|
|
|
|
|
find_package(Boost 1.67.0
|
|
|
|
|
REQUIRED
|
|
|
|
|
chrono filesystem iostreams program_options system thread ${boost_test_lib}
|
2018-02-10 14:59:45 +01:00
|
|
|
)
|
2019-08-11 18:17:22 +02:00
|
|
|
|
|
|
|
|
find_package(Event REQUIRED)
|
2019-03-29 21:52:07 +01:00
|
|
|
|
2019-08-11 18:17:22 +02:00
|
|
|
message ("===== Find optional dependencies")
|
|
|
|
|
|
2020-04-22 17:58:42 +02:00
|
|
|
find_package(ZMQ 4.0) # ZeroMQ
|
2019-08-11 18:17:22 +02:00
|
|
|
if (${ZMQ_FOUND})
|
|
|
|
|
set (ENABLE_ZMQ 1)
|
|
|
|
|
else ()
|
|
|
|
|
# remove "NOTFOUND" so we can just link to it, which then is a no-op
|
|
|
|
|
set (ZMQ_LIBRARIES "")
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
find_package(Miniupnpc)
|
|
|
|
|
if (${MINIUPNP_FOUND})
|
|
|
|
|
set (USE_UPNP 1)
|
|
|
|
|
else ()
|
|
|
|
|
set (MINIUPNP_LIBRARY "")
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
find_package(Qt5Core)
|
|
|
|
|
if (${Qt5Core_FOUND})
|
|
|
|
|
message("-- Qt5 found, version ${Qt5Core_VERSION_STRING}")
|
|
|
|
|
find_package(Qt5Network)
|
2019-09-23 11:44:46 +02:00
|
|
|
if (NOT ${Qt5Network_FOUND})
|
|
|
|
|
message("Missing Qt5 (network) library, not building bitcore-proxy")
|
|
|
|
|
endif ()
|
2019-08-11 18:17:22 +02:00
|
|
|
else()
|
2022-02-14 17:04:24 +01:00
|
|
|
message("Missing qt5 (core) library, not building indexer, txVulcano, bitcore-proxy, many tests")
|
2019-08-11 18:17:22 +02:00
|
|
|
endif()
|
2018-02-10 14:59:45 +01:00
|
|
|
|
|
|
|
|
######################
|
|
|
|
|
#### Generate config.h
|
|
|
|
|
######################
|
|
|
|
|
|
|
|
|
|
# first optional stuff so all the non-optional errors are at the bottom;
|
|
|
|
|
|
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
|
find_path (HAVE_BYTESWAP_H byteswap.h)
|
|
|
|
|
check_symbol_exists(bswap_16 "byteswap.h" HAVE_DECL_BSWAP_16)
|
|
|
|
|
check_symbol_exists(bswap_32 "byteswap.h" HAVE_DECL_BSWAP_32)
|
|
|
|
|
check_symbol_exists(bswap_64 "byteswap.h" HAVE_DECL_BSWAP_64)
|
|
|
|
|
find_path (HAVE_ENDIAN_H endian.h)
|
|
|
|
|
find_path (HAVE_SYS_ENDIAN_H sys/endian.h)
|
|
|
|
|
check_symbol_exists(le16toh "endian.h" HAVE_DECL_LE16TOH)
|
|
|
|
|
check_symbol_exists(be16toh "endian.h" HAVE_DECL_BE16TOH)
|
|
|
|
|
check_symbol_exists(be32toh "endian.h" HAVE_DECL_BE32TOH)
|
|
|
|
|
check_symbol_exists(be64toh "endian.h" HAVE_DECL_BE64TOH)
|
|
|
|
|
check_symbol_exists(htobe16 "endian.h" HAVE_DECL_HTOBE16)
|
|
|
|
|
check_symbol_exists(htobe32 "endian.h" HAVE_DECL_HTOBE32)
|
|
|
|
|
check_symbol_exists(htobe64 "endian.h" HAVE_DECL_HTOBE64)
|
|
|
|
|
check_symbol_exists(htole16 "endian.h" HAVE_DECL_HTOLE16)
|
|
|
|
|
check_symbol_exists(htole32 "endian.h" HAVE_DECL_HTOLE32)
|
|
|
|
|
check_symbol_exists(htole64 "endian.h" HAVE_DECL_HTOLE64)
|
|
|
|
|
check_symbol_exists(le16toh "endian.h" HAVE_DECL_LE16TOH)
|
|
|
|
|
check_symbol_exists(le32toh "endian.h" HAVE_DECL_LE32TOH)
|
|
|
|
|
check_symbol_exists(le64toh "endian.h" HAVE_DECL_LE64TOH)
|
|
|
|
|
find_path (HAVE_SYS_PRCTL_H sys/prctl.h)
|
|
|
|
|
find_path (HAVE_SYS_SELECT_H sys/select.h)
|
|
|
|
|
check_symbol_exists(strnlen "string.h" HAVE_DECL_STRNLEN)
|
|
|
|
|
if (HAVE_DECL_STRNLEN) #default is 1.
|
|
|
|
|
else () # set to zero instead of empty
|
|
|
|
|
set (HAVE_DECL_STRNLEN 0)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-10-10 20:51:34 +02:00
|
|
|
include(CheckBuiltinExists)
|
|
|
|
|
check_builtin_exist(__builtin_popcount HAVE_DECL___BUILTIN_POPCOUNT)
|
|
|
|
|
|
2018-02-10 14:59:45 +01:00
|
|
|
set (WORDS_BIGENDIAN ${CMAKE_WORDS_BIGENDIAN})
|
|
|
|
|
include (TestBigEndian)
|
|
|
|
|
test_big_endian(CMAKE_WORDS_BIGENDIAN)
|
|
|
|
|
|
2019-09-07 20:01:27 +02:00
|
|
|
include(CheckCXXSourceCompiles)
|
2018-02-10 14:59:45 +01:00
|
|
|
# older cmake doesn't set C++11 flags, do it ourselves.
|
|
|
|
|
set (_V "CPP11_ARGS")
|
|
|
|
|
foreach (ARG "" "-std=gnu++11" "-std=c++11")
|
|
|
|
|
set (CMAKE_REQUIRED_FLAGS ${ARG})
|
2019-09-07 20:01:27 +02:00
|
|
|
check_cxx_source_compiles(
|
2018-02-10 14:59:45 +01:00
|
|
|
"#if __cplusplus < 201103L
|
|
|
|
|
# error
|
|
|
|
|
#endif
|
|
|
|
|
int main() {}
|
|
|
|
|
"
|
|
|
|
|
${_V})
|
|
|
|
|
if (${_V})
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARG}")
|
|
|
|
|
break()
|
|
|
|
|
endif()
|
|
|
|
|
set (_V "${_V}_")
|
|
|
|
|
endforeach()
|
|
|
|
|
|
2019-09-07 20:01:27 +02:00
|
|
|
check_cxx_source_compiles(
|
|
|
|
|
"#include <string.h>
|
|
|
|
|
int main() {
|
|
|
|
|
char buffer[10];
|
|
|
|
|
const char* c = strerror_r(0, buffer, 3);
|
|
|
|
|
(void)c;
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
STRERROR_R_CHAR_P)
|
|
|
|
|
|
2018-02-10 14:59:45 +01:00
|
|
|
configure_file (
|
|
|
|
|
"${CMAKE_SOURCE_DIR}/libs/config/flowee-config.h.in"
|
|
|
|
|
${CMAKE_BINARY_DIR}/include/config/flowee-config.h
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND support/genbuild.sh ${CMAKE_BINARY_DIR}/include/build.h ${CMAKE_SOURCE_DIR}
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
|
)
|
|
|
|
|
add_definitions(-DHAVE_CONFIG_H -DHAVE_BUILD_INFO)
|
|
|
|
|
|
2018-11-13 23:07:30 +01:00
|
|
|
# no-deprecated is needed for dbwrapper (leveldb)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla -pthread -Wno-deprecated ")
|
2018-02-10 14:59:45 +01:00
|
|
|
|
2019-08-11 18:17:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
######################
|
|
|
|
|
#### Include hierarchy
|
|
|
|
|
######################
|
|
|
|
|
|
|
|
|
|
# define the include dirs for each section
|
2020-04-08 20:45:16 +02:00
|
|
|
set(3RDPARTY_INCLUDES ${CMAKE_SOURCE_DIR}/libs/3rdparty/secp256k1/include)
|
2019-08-11 18:17:22 +02:00
|
|
|
set(LIBCRYPTO_INCLUDES
|
|
|
|
|
${3RDPARTY_INCLUDES}
|
|
|
|
|
${Boost_INCLUDE_DIRS}
|
|
|
|
|
${OPENSSL_INCLUDE_DIR}
|
|
|
|
|
${CMAKE_SOURCE_DIR}/libs/crypto
|
|
|
|
|
${CMAKE_SOURCE_DIR}/libs
|
|
|
|
|
)
|
2022-05-01 13:55:08 +02:00
|
|
|
#message ("OpenSSL includes: ${OPENSSL_INCLUDE_DIR}")
|
2019-08-11 18:17:22 +02:00
|
|
|
set(LIBUTILS_INCLUDES ${LIBCRYPTO_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utils ${CMAKE_SOURCE_DIR}/libs/interfaces)
|
|
|
|
|
set(LIBNETWORKMANAGER_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/networkmanager)
|
|
|
|
|
set(LIBAPPUTILS_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/apputils)
|
|
|
|
|
set(LIBUTXO_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utxo)
|
2019-09-23 11:07:45 +02:00
|
|
|
set(LIBHTTPENGINE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/httpengine ${CMAKE_BINARY_DIR}/libs/httpengine)
|
2019-08-11 18:17:22 +02:00
|
|
|
|
|
|
|
|
|
2022-02-14 17:04:24 +01:00
|
|
|
# these two should only ever be used by the hub and the unit tests.
|
2022-02-22 18:27:48 +01:00
|
|
|
set(LIBSERVER_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/hub ${CMAKE_SOURCE_DIR}/hub/server)
|
|
|
|
|
set(LIBAPI_INCLUDES ${LIBSERVER_INCLUDES} ${CMAKE_SOURCE_DIR}/hub/api)
|
2020-04-17 19:33:06 +02:00
|
|
|
set(LIBP2P_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/p2p)
|
2019-08-11 18:17:22 +02:00
|
|
|
|
|
|
|
|
|
2018-02-10 14:59:45 +01:00
|
|
|
add_subdirectory(libs)
|
|
|
|
|
add_subdirectory(hub)
|
|
|
|
|
if (build_tests)
|
|
|
|
|
add_subdirectory(testing)
|
|
|
|
|
endif ()
|
2018-03-08 15:31:11 +01:00
|
|
|
if (${Qt5Core_FOUND})
|
2022-02-14 17:53:47 +01:00
|
|
|
add_subdirectory(txVulcano)
|
2019-03-30 14:26:00 +01:00
|
|
|
add_subdirectory(indexer)
|
2018-09-05 22:52:45 +02:00
|
|
|
add_subdirectory(unspentdb)
|
2019-09-23 11:44:46 +02:00
|
|
|
if (${Qt5Network_FOUND})
|
|
|
|
|
add_subdirectory(bitcore-proxy)
|
2020-09-02 14:03:01 +02:00
|
|
|
add_subdirectory(rest-service)
|
2019-09-23 11:44:46 +02:00
|
|
|
endif ()
|
2018-03-08 15:31:11 +01:00
|
|
|
endif ()
|
2019-11-04 00:02:38 +01:00
|
|
|
|