2018-12-27 18:50:45 +03:00
|
|
|
cmake_minimum_required(VERSION 2.8.6)
|
|
|
|
|
|
|
|
|
|
PROJECT(Zano)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set(VERSION "1.0")
|
|
|
|
|
|
2020-01-27 21:53:00 +01:00
|
|
|
# if(POLICY CMP0043)
|
|
|
|
|
# cmake_policy(SET CMP0043 OLD)
|
|
|
|
|
# endif()
|
2018-12-27 18:50:45 +03:00
|
|
|
|
2020-01-27 21:53:00 +01:00
|
|
|
# if(POLICY CMP0020)
|
|
|
|
|
# cmake_policy(SET CMP0020 OLD)
|
|
|
|
|
# endif()
|
2018-12-27 18:50:45 +03:00
|
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
|
2019-05-23 02:54:56 +03:00
|
|
|
# build types
|
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
|
# single configurations, defaults to Release
|
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
# multi configurations for MSVC and XCode
|
2020-01-23 03:26:25 +01:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Release")
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
|
|
|
|
|
endif()
|
2019-05-23 02:54:56 +03:00
|
|
|
endif()
|
|
|
|
|
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
2018-12-27 18:50:45 +03:00
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10.5)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers for MSVC")
|
|
|
|
|
|
2019-09-27 22:47:24 +02:00
|
|
|
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
|
2019-08-29 22:48:15 +02:00
|
|
|
|
2018-12-27 18:50:45 +03:00
|
|
|
add_definitions(-DSTATICLIB)
|
|
|
|
|
|
|
|
|
|
set(TESTNET FALSE CACHE BOOL "Compile for testnet")
|
|
|
|
|
if(TESTNET)
|
|
|
|
|
message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!")
|
|
|
|
|
add_definitions(-DTESTNET)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(BUILD_GUI FALSE CACHE BOOL "Build qt-daemon")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
|
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
|
# Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-02-16 01:44:59 +00:00
|
|
|
# TODO(unassigned): expand on types and versions, and then refactor.
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
|
set(CLANG TRUE)
|
|
|
|
|
endif()
|
2018-12-27 18:50:45 +03:00
|
|
|
|
|
|
|
|
if(MSVC)
|
2019-05-02 17:11:51 +03:00
|
|
|
add_definitions("/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D__SSE4_1__")
|
|
|
|
|
add_compile_options(/bigobj /Zm1000 /Z7 /MP2 /W3 /GS- /wd4996 /wd4503 /wd4345 /wd4091 /FIinline_c.h)
|
2018-12-27 18:50:45 +03:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760 /DEBUG dbghelp.lib")
|
|
|
|
|
if(STATIC)
|
|
|
|
|
foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
|
|
|
|
|
string(REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
|
|
|
|
|
endforeach()
|
|
|
|
|
endif()
|
|
|
|
|
include_directories(SYSTEM src/platform/msc)
|
|
|
|
|
else()
|
|
|
|
|
set(ARCH default CACHE STRING "CPU to build for: -march value or default")
|
|
|
|
|
if("${ARCH}" STREQUAL "default")
|
|
|
|
|
set(ARCH_FLAG "")
|
|
|
|
|
else()
|
|
|
|
|
set(ARCH_FLAG "-march=${ARCH}")
|
|
|
|
|
endif()
|
2020-01-09 17:06:02 +01:00
|
|
|
set(WARNINGS "-Wno-implicit-function-declaration -Wall -Wextra -Wpointer-arith -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-aggregate-return")
|
2018-12-27 18:50:45 +03:00
|
|
|
# if(NOT APPLE)
|
|
|
|
|
# set(WARNINGS "${WARNINGS} -Werror")
|
|
|
|
|
# endif()
|
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
|
set(WARNINGS "${WARNINGS} -Wno-shift-count-overflow -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration")
|
|
|
|
|
else()
|
|
|
|
|
set(WARNINGS "${WARNINGS} -Wno-error=write-strings -Wlogical-op -Wno-error=maybe-uninitialized")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0))
|
|
|
|
|
set(CMAKE_AR "gcc-ar")
|
|
|
|
|
set(CMAKE_RANLIB "gcc-ranlib")
|
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT APPLE)
|
|
|
|
|
set(CMAKE_AR "llvm-ar")
|
|
|
|
|
set(CMAKE_RANLIB "llvm-ranlib")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(MINGW)
|
|
|
|
|
set(WARNINGS "${WARNINGS} -Wno-error=unused-value")
|
|
|
|
|
set(MINGW_FLAG "-DWIN32_LEAN_AND_MEAN")
|
|
|
|
|
include_directories(SYSTEM src/platform/mingw)
|
|
|
|
|
else()
|
|
|
|
|
set(MINGW_FLAG "")
|
|
|
|
|
endif()
|
|
|
|
|
if(APPLE)
|
|
|
|
|
set(APPLE_FLAG "-DGTEST_USE_OWN_TR1_TUPLE=1")
|
|
|
|
|
else()
|
|
|
|
|
set(APPLE_FLAG "")
|
|
|
|
|
endif()
|
|
|
|
|
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wstrict-prototypes")
|
|
|
|
|
set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
|
|
|
|
|
try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/utils/test-static-assert.c" COMPILE_DEFINITIONS "-std=c11")
|
|
|
|
|
if(STATIC_ASSERT_RES)
|
|
|
|
|
set(STATIC_ASSERT_FLAG "")
|
|
|
|
|
else()
|
|
|
|
|
set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert")
|
|
|
|
|
endif()
|
2019-02-16 01:44:59 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}")
|
|
|
|
|
if (NOT APPLE AND NOT MSVC)
|
|
|
|
|
if (CLANG)
|
|
|
|
|
set(LLVM_USE_LINKER "gold")
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
|
|
|
|
endif()
|
2018-12-27 18:50:45 +03:00
|
|
|
endif()
|
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
|
|
|
|
|
set(DEBUG_FLAGS "-g3 -O0") #set(DEBUG_FLAGS "-g3 -Og")
|
|
|
|
|
else()
|
|
|
|
|
set(DEBUG_FLAGS "-g3 -O0")
|
|
|
|
|
endif()
|
|
|
|
|
set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable")
|
|
|
|
|
if(NOT APPLE)
|
|
|
|
|
set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto")
|
|
|
|
|
endif()
|
|
|
|
|
#if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
|
|
|
|
|
# set(RELEASE_FLAGS "${RELEASE_FLAGS} -fno-fat-lto-objects")
|
|
|
|
|
#endif()
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
|
|
|
|
if(STATIC)
|
|
|
|
|
if(APPLE)
|
|
|
|
|
message(SEND_ERROR "Static build is not supported on MacOS X")
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(STATIC)
|
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
|
set(Boost_USE_STATIC_RUNTIME ON)
|
|
|
|
|
endif()
|
2020-01-09 17:06:02 +01:00
|
|
|
|
|
|
|
|
|
2020-01-21 01:31:16 +01:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|
|
|
|
set(Boost_INCLUDE_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/include")
|
|
|
|
|
set(Boost_LIBRARY_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/ios/")
|
|
|
|
|
set(Boost_LIBRARIES "libboost.a")
|
|
|
|
|
set(Boost_VERSION "ofxiOSBoost 1.60.0")
|
|
|
|
|
else()
|
2020-01-23 03:26:25 +01:00
|
|
|
find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem locale thread timer date_time chrono regex serialization atomic program_options ) #locale
|
2020-01-21 01:31:16 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-01-09 17:06:02 +01:00
|
|
|
|
2018-12-27 18:50:45 +03:00
|
|
|
|
|
|
|
|
message(STATUS "Boost: ${Boost_VERSION} from ${Boost_LIBRARY_DIRS}")
|
|
|
|
|
|
|
|
|
|
|
2019-03-25 01:30:20 +01:00
|
|
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/contrib/ethereum/libethash)
|
2018-12-27 18:50:45 +03:00
|
|
|
if(MINGW)
|
|
|
|
|
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
|
|
|
|
|
elseif(NOT MSVC)
|
|
|
|
|
if(NOT APPLE)
|
|
|
|
|
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
|
|
|
|
|
if(STATIC)
|
|
|
|
|
message("NOTICE: Including static ICU libraries")
|
|
|
|
|
set(Boost_LIBRARIES "${Boost_LIBRARIES};icui18n.a;icuuc.a;icudata.a;dl")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(BUILD_GUI)
|
|
|
|
|
cmake_minimum_required(VERSION 2.8.11)
|
|
|
|
|
find_package(Qt5Widgets REQUIRED)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
|
|
|
|
|
if (NOT COMMIT_ID_IN_VERSION)
|
|
|
|
|
set(VERSION "${VERSION}-unknown")
|
|
|
|
|
configure_file("src/version.h.in" "version/version.h")
|
|
|
|
|
add_custom_target(version ALL)
|
|
|
|
|
elseif(DEFINED COMMIT)
|
|
|
|
|
string(REPLACE "." "\\." VERSION_RE "${VERSION}")
|
|
|
|
|
if(NOT REFS MATCHES "(\\(|, )tag: v${VERSION_RE}(\\)|, )")
|
|
|
|
|
set(VERSION "${VERSION}-g${COMMIT}")
|
|
|
|
|
endif()
|
|
|
|
|
configure_file("src/version.h.in" "version/version.h")
|
|
|
|
|
add_custom_target(version ALL)
|
|
|
|
|
else()
|
|
|
|
|
find_package(Git QUIET)
|
|
|
|
|
if(Git_FOUND OR GIT_FOUND)
|
|
|
|
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
|
|
|
|
add_custom_target(version ALL "${CMAKE_COMMAND}" "-D" "VERSION=${VERSION}" "-D" "GIT=${GIT_EXECUTABLE}" "-D" "TO=${CMAKE_BINARY_DIR}/version/version.h" "-P" "src/version.cmake" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS "WARNING: Git was not found!")
|
|
|
|
|
set(VERSION "${VERSION}-unknown")
|
|
|
|
|
configure_file("src/version.h.in" "version/version.h")
|
|
|
|
|
add_custom_target(version ALL)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-02-20 02:32:35 +00:00
|
|
|
set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests")
|
2019-10-25 00:13:38 +02:00
|
|
|
set(DISABLE_MDBX FALSE CACHE BOOL "Exclude mdbx from build(need for a first time)")
|
|
|
|
|
if(NOT DISABLE_MDBX)
|
|
|
|
|
add_definitions(-DENABLED_ENGINE_MDBX)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-08-31 14:41:18 +02:00
|
|
|
|
2018-12-27 18:50:45 +03:00
|
|
|
add_subdirectory(contrib)
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
2019-02-20 02:32:35 +00:00
|
|
|
if (BUILD_TESTS)
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|