diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f2c84a516..431d488ff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,68 +1,96 @@ # Copyright (c) 2017 The Bitcoin developers set(CMAKE_CXX_STANDARD 11) add_subdirectory(config) add_subdirectory(crypto) add_subdirectory(leveldb) add_subdirectory(secp256k1) add_subdirectory(univalue) # Because the Bitcoin ABc source code is disorganised, we # end up with a bunch of libraries without any aparent # cohesive structure. This is inherited from Bitcoin Core # and reflecting this. # TODO: Improve the structure once cmake is rocking. # Various completely unrelated features shared by all executables. add_library(util chainparamsbase.cpp clientversion.cpp compat/glibc_sanity.cpp compat/glibcxx_sanity.cpp compat/strnlen.cpp random.cpp rpc/protocol.cpp support/cleanse.cpp support/lockedpool.cpp sync.cpp threadinterrupt.cpp uint256.cpp util.cpp utilmoneystr.cpp utilstrencodings.cpp utiltime.cpp ) target_compile_definitions(util PUBLIC HAVE_CONFIG_H) target_include_directories(util PUBLIC . # To access the config. # TODO: Make compat its own lib and just import it. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/config ) # Dependencies set(BOOST_PACKAGES_REQUIRED filesystem) if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(Boost_USE_STATIC_LIBS ON) list(APPEND BOOST_PACKAGES_REQUIRED thread_win32) else() list(APPEND BOOST_PACKAGES_REQUIRED date_time thread) endif() function(prepend var prefix) set(listVar "") foreach(f ${ARGN}) list(APPEND listVar "${prefix}${f}") endforeach(f) set(${var} "${listVar}" PARENT_SCOPE) endfunction(prepend) prepend(BOOST_LIBRARIES "Boost::" ${BOOST_PACKAGES_REQUIRED}) find_package(Boost 1.55 REQUIRED ${BOOST_PACKAGES_REQUIRED}) target_link_libraries(util univalue ${BOOST_LIBRARIES}) + +# More completely unrelated features shared by all executables. +# Because nothing says this is different from util than "common" +add_library(common + amount.cpp + base58.cpp + cashaddr.cpp + cashaddrenc.cpp + chainparams.cpp + config.cpp + coins.cpp + compressor.cpp + dstencode.cpp + globals.cpp + core_read.cpp + core_write.cpp + key.cpp + keystore.cpp + netaddress.cpp + netbase.cpp + protocol.cpp + scheduler.cpp + script/sign.cpp + script/standard.cpp + warnings.cpp +) + +target_link_libraries(common util secp256k1) diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 8dd799510..7213a672f 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -1,62 +1,64 @@ # Copyright (c) 2017 The Bitcoin developers # This generates config.h which provides numerous defines # about the state of the plateform we are building on. include(CheckIncludeFiles) include(CheckSymbolExists) # Version set(CLIENT_VERSION_MAJOR 0) set(CLIENT_VERSION_MINOR 16) set(CLIENT_VERSION_REVISION 2) set(CLIENT_VERSION_BUILD 0) +option(CLIENT_VERSION_IS_RELEASE "Build a release version" OFF) + # Copyright set(COPYRIGHT_YEAR 2017) set(COPYRIGHT_HOLDERS "The %s developers") set(COPYRIGHT_HOLDERS_SUBSTITUTION Bitcoin) # Endianness check_include_files("endian.h" HAVE_ENDIAN_H) check_include_files("sys/endian.h" HAVE_SYS_ENDIAN_H) if(HAVE_ENDIAN_H) set(ENDIAN_FILE "endian.h") elseif(HAVE_SYS_ENDIAN_H) set(ENDIAN_FILE "sys/endian.h") else() endif() if(ENDIAN_FILE) check_symbol_exists(htole16 ${ENDIAN_FILE} HAVE_DECL_HTOLE16) check_symbol_exists(htobe16 ${ENDIAN_FILE} HAVE_DECL_HTOBE16) check_symbol_exists(be16toh ${ENDIAN_FILE} HAVE_DECL_BE16TOH) check_symbol_exists(le16toh ${ENDIAN_FILE} HAVE_DECL_LE16TOH) check_symbol_exists(htobe32 ${ENDIAN_FILE} HAVE_DECL_HTOBE32) check_symbol_exists(htole32 ${ENDIAN_FILE} HAVE_DECL_HTOLE32) check_symbol_exists(be32toh ${ENDIAN_FILE} HAVE_DECL_BE32TOH) check_symbol_exists(le32toh ${ENDIAN_FILE} HAVE_DECL_LE32TOH) check_symbol_exists(htobe64 ${ENDIAN_FILE} HAVE_DECL_HTOBE64) check_symbol_exists(htole64 ${ENDIAN_FILE} HAVE_DECL_HTOLE64) check_symbol_exists(be64toh ${ENDIAN_FILE} HAVE_DECL_BE64TOH) check_symbol_exists(le64toh ${ENDIAN_FILE} HAVE_DECL_LE64TOH) endif() # Byte swap check_include_files("byteswap.h" HAVE_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) # Bitmanip intrinsics check_symbol_exists(__builtin_clz "" HAVE_DECL___BUILTIN_CLZ) check_symbol_exists(__builtin_clzl "" HAVE_DECL___BUILTIN_CLZL) check_symbol_exists(__builtin_clzll "" HAVE_DECL___BUILTIN_CLZLL) # Various system libraries check_symbol_exists(strnlen "string.h" HAVE_DECL_STRNLEN) # Generate the config configure_file(bitcoin-config.h.cmake.in bitcoin-config.h ESCAPE_QUOTES) diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in index c47aaf335..0e4137203 100644 --- a/src/config/bitcoin-config.h.cmake.in +++ b/src/config/bitcoin-config.h.cmake.in @@ -1,43 +1,44 @@ // Copyright (c) 2017 The Bitcoin developers #ifndef BITCOIN_CONFIG_BITCOIN_CONFIG_H #define BITCOIN_CONFIG_BITCOIN_CONFIG_H #define CLIENT_VERSION_MAJOR ${CLIENT_VERSION_MAJOR} #define CLIENT_VERSION_MINOR ${CLIENT_VERSION_MINOR} #define CLIENT_VERSION_REVISION ${CLIENT_VERSION_REVISION} #define CLIENT_VERSION_BUILD ${CLIENT_VERSION_BUILD} +#cmakedefine01 CLIENT_VERSION_IS_RELEASE #define COPYRIGHT_YEAR "${COPYRIGHT_YEAR}" #define COPYRIGHT_HOLDERS "${COPYRIGHT_HOLDERS}" #define COPYRIGHT_HOLDERS_SUBSTITUTION "${COPYRIGHT_HOLDERS_SUBSTITUTION}" #cmakedefine HAVE_ENDIAN_H @HAVE_ENDIAN_H@ #cmakedefine HAVE_SYS_ENDIAN_H @HAVE_SYS_ENDIAN_H@ #cmakedefine HAVE_DECL_HTOLE16 @HAVE_DECL_HTOLE16@ #cmakedefine HAVE_DECL_HTOBE16 @HAVE_DECL_HTOBE16@ #cmakedefine HAVE_DECL_BE16TOH @HAVE_DECL_BE16TOH@ #cmakedefine HAVE_DECL_LE16TOH @HAVE_DECL_LE16TOH@ #cmakedefine HAVE_DECL_HTOBE32 @HAVE_DECL_HTOBE32@ #cmakedefine HAVE_DECL_HTOLE32 @HAVE_DECL_HTOLE32@ #cmakedefine HAVE_DECL_BE32TOH @HAVE_DECL_BE32TOH@ #cmakedefine HAVE_DECL_LE32TOH @HAVE_DECL_LE32TOH@ #cmakedefine HAVE_DECL_HTOBE64 @HAVE_DECL_HTOBE64@ #cmakedefine HAVE_DECL_HTOLE64 @HAVE_DECL_HTOLE64@ #cmakedefine HAVE_DECL_BE64TOH @HAVE_DECL_BE64TOH@ #cmakedefine HAVE_DECL_LE64TOH @HAVE_DECL_LE64TOH@ #cmakedefine HAVE_BYTESWAP_H @HAVE_BYTESWAP_H@ #cmakedefine HAVE_DECL_BSWAP_16 @HAVE_DECL_BSWAP_16@ #cmakedefine HAVE_DECL_BSWAP_32 @HAVE_DECL_BSWAP_32@ #cmakedefine HAVE_DECL_BSWAP_64 @HAVE_DECL_BSWAP_64@ #cmakedefine HAVE_DECL___BUILTIN_CLZ @HAVE_DECL___BUILTIN_CLZ@ #cmakedefine HAVE_DECL___BUILTIN_CLZL @HAVE_DECL___BUILTIN_CLZL@ #cmakedefine HAVE_DECL___BUILTIN_CLZLL @HAVE_DECL___BUILTIN_CLZLL@ #cmakedefine HAVE_DECL_STRNLEN @HAVE_DECL_STRNLEN@ #endif // BITCOIN_BITCOIN_CONFIG_H diff --git a/src/leveldb/CMakeLists.txt b/src/leveldb/CMakeLists.txt index a9a7098fb..7ce5e0043 100644 --- a/src/leveldb/CMakeLists.txt +++ b/src/leveldb/CMakeLists.txt @@ -1,214 +1,218 @@ # Copyright 2017 The LEVELDB Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. See the AUTHORS file for names of contributors. cmake_minimum_required(VERSION 3.1) project(Leveldb VERSION 0.1.0 LANGUAGES C CXX) # This project can take advantage of C++11. set(CMAKE_CXX_STANDARD 11) option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON) include(TestBigEndian) test_big_endian(LEVELDB_IS_BIG_ENDIAN) include(CheckIncludeFile) check_include_file("unistd.h" HAVE_UNISTD_H) include(CheckIncludeFileCXX) check_include_file_cxx("atomic" LEVELDB_ATOMIC_PRESENT) include(CheckLibraryExists) check_library_exists(crc32c crc32c_value "" HAVE_CRC32C) check_library_exists(snappy snappy_compress "" HAVE_SNAPPY) include(CheckSymbolExists) check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC) configure_file( port/port_config.h.cmake.in include/port/port_config.h ) include_directories(.) add_library(leveldb db/builder.cc db/c.cc db/dbformat.cc db/db_impl.cc db/db_iter.cc db/dumpfile.cc db/filename.cc db/log_reader.cc db/log_writer.cc db/memtable.cc db/repair.cc db/table_cache.cc db/version_edit.cc db/version_set.cc db/write_batch.cc table/block_builder.cc table/block.cc table/filter_block.cc table/format.cc table/iterator.cc table/merger.cc table/table_builder.cc table/table.cc table/two_level_iterator.cc util/arena.cc util/bloom.cc util/cache.cc util/coding.cc util/comparator.cc util/crc32c.cc util/env.cc util/env_posix.cc util/filter_policy.cc util/hash.cc util/histogram.cc util/logging.cc util/options.cc util/status.cc # Always include that guy even when not using SSE or posix. # TODO: proper support of SSE. port/port_posix_sse.cc ) target_include_directories(leveldb PUBLIC include "${PROJECT_BINARY_DIR}/include" ) # Select the proper port: posix or Windows. if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(LEVELDB_PLATFORM WINDOWS) set(LEVELDB_OS WINDOWS) target_sources(leveldb PRIVATE util/env_win.cc port/port_win.cc ) target_compile_definitions(leveldb PRIVATE WINVER=0x0500 __USE_MINGW_ANSI_STDIO=1 ) find_package(SHLWAPI REQUIRED) target_link_libraries(leveldb ${SHLWAPI_LIBRARY}) target_include_directories(leveldb PUBLIC ${SHLWAPI_INCLUDE_DIR}) else() set(LEVELDB_PLATFORM POSIX) target_sources(leveldb PRIVATE port/port_posix.cc ) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) target_link_libraries(leveldb Threads::Threads) # TODO: If the plateform supports SSE4.2 activate # LEVELDB_PLATFORM_POSIX_SSE and the proper compiler flags. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(LEVELDB_OS LINUX) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(LEVELDB_OS MACOSX) elseif(${CMAKE_SYSTEM_NAME} MATCHES "(Solaris|SunOS)") set(LEVELDB_OS SOLARIS) elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(LEVELDB_OS FREEBSD) elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") set(LEVELDB_OS NETBSD) elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") set(LEVELDB_OS OPENBSD) elseif(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly") set(LEVELDB_OS DRAGONFLYBSD) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") set(LEVELDB_OS ANDROID) elseif(${CMAKE_SYSTEM_NAME} MATCHES "HPUX") # No idea what's the proper system name is here. set(LEVELDB_OS HPUX) elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS") # No idea what's the proper system name is here. set(LEVELDB_OS IOS) else() set(LEVELDB_OS LINUX) endif() endif() target_compile_definitions(leveldb PUBLIC - LEVELDB_PLATFORM_${LEVELDB_PLATFORM} OS_${LEVELDB_OS} + LEVELDB_PLATFORM_${LEVELDB_PLATFORM} ) # Right now this is not used but the latest version of leveldb uses this # so we might as well be ready for it. if (HAVE_CRC32C) target_link_libraries(leveldb crc32c) endif (HAVE_CRC32C) if (HAVE_SNAPPY) target_link_libraries(leveldb snappy) endif (HAVE_SNAPPY) # The libmemenv library. add_library(memenv helpers/memenv/memenv.cc) target_include_directories(memenv PUBLIC include) -target_compile_definitions(memenv PUBLIC LEVELDB_PLATFORM_${LEVELDB_PLATFORM}) +target_compile_definitions(memenv + PUBLIC + OS_${LEVELDB_OS} + LEVELDB_PLATFORM_${LEVELDB_PLATFORM} +) if(LEVELDB_BUILD_TESTS) enable_testing() add_library(leveldb_test_base util/testharness.cc util/testutil.cc ) target_link_libraries(leveldb_test_base leveldb) function(create_leveldb_test NAME FILES) add_executable(${NAME} ${FILES}) target_link_libraries(${NAME} leveldb_test_base) add_test(NAME ${NAME} COMMAND ${NAME}) endfunction() create_leveldb_test(autocompact_test db/autocompact_test.cc) create_leveldb_test(corruption_test db/corruption_test.cc) create_leveldb_test(db_test db/db_test.cc) create_leveldb_test(dbformat_test db/dbformat_test.cc) create_leveldb_test(fault_injection_test db/fault_injection_test.cc) create_leveldb_test(filename_test db/filename_test.cc) create_leveldb_test(log_test db/log_test.cc) create_leveldb_test(recovery_test db/recovery_test.cc) create_leveldb_test(skiplist_test db/skiplist_test.cc) create_leveldb_test(version_edit_test db/version_edit_test.cc) create_leveldb_test(version_set_test db/version_set_test.cc) create_leveldb_test(write_batch_test db/write_batch_test.cc) create_leveldb_test(issue178_test issues/issue178_test.cc) create_leveldb_test(issue200_test issues/issue200_test.cc) create_leveldb_test(filter_block_test table/filter_block_test.cc) create_leveldb_test(table_test table/table_test.cc) create_leveldb_test(arena_test util/arena_test.cc) create_leveldb_test(bloom_test util/bloom_test.cc) create_leveldb_test(cache_test util/cache_test.cc) create_leveldb_test(coding_test util/coding_test.cc) create_leveldb_test(crc32c_test util/crc32c_test.cc) create_leveldb_test(env_test util/env_test.cc) create_leveldb_test(hash_test util/hash_test.cc) create_leveldb_test(memenv_test helpers/memenv/memenv_test.cc) target_link_libraries(memenv_test memenv) # These tests only work on posix if(${LEVELDB_PLATFORM} MATCHES "POSIX") create_leveldb_test(c_test db/c_test.c) create_leveldb_test(env_posix_test util/env_posix_test.cc) endif() endif(LEVELDB_BUILD_TESTS)