2019-02-12 01:16:40 +08:00
|
|
|
set(FORCE_ALL_COMPONENTS OFF CACHE BOOL "Fails cmake if not all dependencies are found")
|
|
|
|
|
2019-06-11 06:30:57 +08:00
|
|
|
################################################################################
|
2021-01-22 04:35:27 +08:00
|
|
|
# jemalloc
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
include(Jemalloc)
|
|
|
|
|
|
|
|
################################################################################
|
2019-06-11 06:30:57 +08:00
|
|
|
# Valgrind
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if(USE_VALGRIND)
|
|
|
|
find_package(Valgrind REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2019-02-08 14:18:31 +08:00
|
|
|
################################################################################
|
2020-02-14 06:42:45 +08:00
|
|
|
# SSL
|
2019-02-08 14:18:31 +08:00
|
|
|
################################################################################
|
|
|
|
|
2020-04-30 06:16:43 +08:00
|
|
|
include(CheckSymbolExists)
|
2020-09-09 00:30:23 +08:00
|
|
|
|
2020-04-26 08:59:17 +08:00
|
|
|
set(DISABLE_TLS OFF CACHE BOOL "Don't try to find OpenSSL and always build without TLS support")
|
2019-02-08 14:18:31 +08:00
|
|
|
if(DISABLE_TLS)
|
|
|
|
set(WITH_TLS OFF)
|
|
|
|
else()
|
2020-02-14 06:42:45 +08:00
|
|
|
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
|
|
|
find_package(OpenSSL)
|
2020-04-26 08:59:17 +08:00
|
|
|
if(OPENSSL_FOUND)
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
2021-02-09 02:42:07 +08:00
|
|
|
set(WITH_TLS ON)
|
|
|
|
add_compile_options(-DHAVE_OPENSSL)
|
2020-04-30 06:11:35 +08:00
|
|
|
check_symbol_exists("OPENSSL_INIT_NO_ATEXIT" "openssl/crypto.h" OPENSSL_HAS_NO_ATEXIT)
|
2020-04-26 08:59:17 +08:00
|
|
|
if(OPENSSL_HAS_NO_ATEXIT)
|
2021-02-09 01:20:28 +08:00
|
|
|
add_compile_options(-DHAVE_OPENSSL_INIT_NO_AT_EXIT)
|
2020-04-26 08:59:17 +08:00
|
|
|
else()
|
2021-02-09 01:20:28 +08:00
|
|
|
message(STATUS "Found OpenSSL without OPENSSL_INIT_NO_ATEXIT: assuming BoringSSL")
|
2020-04-26 08:59:17 +08:00
|
|
|
endif()
|
2019-02-08 14:18:31 +08:00
|
|
|
else()
|
2020-04-26 08:59:17 +08:00
|
|
|
message(STATUS "OpenSSL was not found - Will compile without TLS Support")
|
|
|
|
message(STATUS "You can set OPENSSL_ROOT_DIR to help cmake find it")
|
2019-02-08 14:18:31 +08:00
|
|
|
set(WITH_TLS OFF)
|
|
|
|
endif()
|
2020-02-22 03:23:51 +08:00
|
|
|
if(WIN32)
|
2021-08-14 04:02:49 +08:00
|
|
|
message(STATUS "TLS is temporarilty disabled on Windows while libressl -> openssl transition happens")
|
2020-02-22 03:23:51 +08:00
|
|
|
set(WITH_TLS OFF)
|
|
|
|
endif()
|
2019-02-08 14:18:31 +08:00
|
|
|
endif()
|
|
|
|
|
2019-02-10 14:08:34 +08:00
|
|
|
################################################################################
|
|
|
|
# Python Bindings
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
find_package(Python COMPONENTS Interpreter)
|
|
|
|
if(Python_Interpreter_FOUND)
|
|
|
|
set(WITH_PYTHON ON)
|
|
|
|
else()
|
2021-08-19 23:39:03 +08:00
|
|
|
message(WARNING "Could not found a suitable python interpreter")
|
2019-02-10 14:08:34 +08:00
|
|
|
set(WITH_PYTHON OFF)
|
|
|
|
endif()
|
|
|
|
|
2021-08-05 21:31:15 +08:00
|
|
|
option(BUILD_PYTHON_BINDING "build python binding" ON)
|
|
|
|
if(NOT BUILD_PYTHON_BINDING OR NOT WITH_PYTHON)
|
|
|
|
set(WITH_PYTHON_BINDING OFF)
|
|
|
|
else()
|
|
|
|
if(WITH_PYTHON)
|
|
|
|
set(WITH_PYTHON_BINDING ON)
|
|
|
|
else()
|
2021-08-19 23:39:03 +08:00
|
|
|
message(WARNING "Python binding depends on Python, but a python interpreter is not found")
|
2021-08-05 21:31:15 +08:00
|
|
|
set(WITH_PYTHON_BINDING OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# C Bindings
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
option(BUILD_C_BINDING "build C binding" ON)
|
2021-08-19 23:39:03 +08:00
|
|
|
if(BUILD_C_BINDING AND NOT WITH_PYTHON)
|
|
|
|
message(WARNING "C binding depends on Python, but a python interpreter is not found")
|
|
|
|
endif()
|
2021-08-05 21:31:15 +08:00
|
|
|
if(BUILD_C_BINDING AND WITH_PYTHON)
|
|
|
|
set(WITH_C_BINDING ON)
|
|
|
|
else()
|
|
|
|
set(WITH_C_BINDING OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Java Bindings
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
option(BUILD_JAVA_BINDING "build java binding" ON)
|
2021-08-19 23:39:03 +08:00
|
|
|
if(BUILD_JAVA_BINDING AND NOT WITH_C_BINDING)
|
|
|
|
message(WARNING "Java binding depends on C binding, but C binding is not enabled")
|
|
|
|
endif()
|
2021-08-05 21:31:15 +08:00
|
|
|
if(NOT BUILD_JAVA_BINDING OR NOT WITH_C_BINDING)
|
|
|
|
set(WITH_JAVA_BINDING OFF)
|
|
|
|
else()
|
|
|
|
set(WITH_JAVA_BINDING OFF)
|
|
|
|
find_package(JNI 1.8)
|
|
|
|
find_package(Java 1.8 COMPONENTS Development)
|
|
|
|
# leave FreeBSD JVM compat for later
|
|
|
|
if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND AND NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") AND WITH_C_BINDING)
|
|
|
|
set(WITH_JAVA_BINDING ON)
|
|
|
|
include(UseJava)
|
|
|
|
enable_language(Java)
|
|
|
|
else()
|
|
|
|
set(WITH_JAVA_BINDING OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-02-10 14:08:34 +08:00
|
|
|
################################################################################
|
|
|
|
# Pip
|
|
|
|
################################################################################
|
|
|
|
|
2021-08-05 21:31:15 +08:00
|
|
|
option(BUILD_DOCUMENTATION "build documentation" ON)
|
2020-02-21 14:48:35 +08:00
|
|
|
find_package(Python3 COMPONENTS Interpreter)
|
2021-08-05 21:31:15 +08:00
|
|
|
if (WITH_PYTHON AND Python3_Interpreter_FOUND AND BUILD_DOCUMENTATION)
|
2019-02-15 08:37:48 +08:00
|
|
|
set(WITH_DOCUMENTATION ON)
|
2019-02-11 02:30:18 +08:00
|
|
|
else()
|
2019-02-15 08:37:48 +08:00
|
|
|
set(WITH_DOCUMENTATION OFF)
|
2019-02-10 14:08:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# GO
|
|
|
|
################################################################################
|
|
|
|
|
2021-08-05 21:31:15 +08:00
|
|
|
option(BUILD_GO_BINDING "build go binding" ON)
|
2021-08-19 23:39:03 +08:00
|
|
|
if(BUILD_GO_BINDING AND NOT WITH_C_BINDING)
|
|
|
|
message(WARNING "Go binding depends on C binding, but C binding is not enabled")
|
|
|
|
endif()
|
2021-08-05 21:31:15 +08:00
|
|
|
if(NOT BUILD_GO_BINDING OR NOT BUILD_C_BINDING)
|
|
|
|
set(WITH_GO_BINDING OFF)
|
2019-02-10 14:08:34 +08:00
|
|
|
else()
|
2021-08-05 21:31:15 +08:00
|
|
|
find_program(GO_EXECUTABLE go)
|
|
|
|
# building the go binaries is currently not supported on Windows
|
|
|
|
if(GO_EXECUTABLE AND NOT WIN32 AND WITH_C_BINDING)
|
|
|
|
set(WITH_GO_BINDING ON)
|
|
|
|
else()
|
|
|
|
set(WITH_GO_BINDING OFF)
|
|
|
|
endif()
|
|
|
|
if (USE_SANITIZER)
|
|
|
|
# Disable building go for sanitizers, since _stacktester doesn't link properly
|
|
|
|
set(WITH_GO_BINDING OFF)
|
|
|
|
endif()
|
2021-03-10 04:55:41 +08:00
|
|
|
endif()
|
2019-02-10 14:08:34 +08:00
|
|
|
|
2019-02-11 02:05:52 +08:00
|
|
|
################################################################################
|
|
|
|
# Ruby
|
|
|
|
################################################################################
|
|
|
|
|
2021-08-05 21:31:15 +08:00
|
|
|
option(BUILD_RUBY_BINDING "build ruby binding" ON)
|
2021-08-19 23:39:03 +08:00
|
|
|
if(BUILD_RUBY_BINDING AND NOT WITH_C_BINDING)
|
|
|
|
message(WARNING "Ruby binding depends on C binding, but C binding is not enabled")
|
|
|
|
endif()
|
2021-08-05 21:31:15 +08:00
|
|
|
if(NOT BUILD_RUBY_BINDING OR NOT BUILD_C_BINDING)
|
|
|
|
set(WITH_RUBY_BINDING OFF)
|
|
|
|
else()
|
|
|
|
find_program(GEM_EXECUTABLE gem)
|
|
|
|
set(WITH_RUBY_BINDING OFF)
|
|
|
|
if(GEM_EXECUTABLE AND WITH_C_BINDING)
|
|
|
|
set(GEM_COMMAND ${RUBY_EXECUTABLE} ${GEM_EXECUTABLE})
|
|
|
|
set(WITH_RUBY_BINDING ON)
|
|
|
|
endif()
|
2019-02-11 02:05:52 +08:00
|
|
|
endif()
|
|
|
|
|
2020-06-11 05:07:49 +08:00
|
|
|
################################################################################
|
|
|
|
# RocksDB
|
|
|
|
################################################################################
|
|
|
|
|
2020-11-06 01:07:53 +08:00
|
|
|
set(SSD_ROCKSDB_EXPERIMENTAL ON CACHE BOOL "Build with experimental RocksDB support")
|
2020-09-09 00:30:23 +08:00
|
|
|
# RocksDB is currently enabled by default for GCC but does not build with the latest
|
|
|
|
# Clang.
|
2020-11-05 05:59:14 +08:00
|
|
|
if (SSD_ROCKSDB_EXPERIMENTAL AND GCC)
|
2020-06-11 05:07:49 +08:00
|
|
|
set(WITH_ROCKSDB_EXPERIMENTAL ON)
|
|
|
|
else()
|
2020-06-11 05:34:00 +08:00
|
|
|
set(WITH_ROCKSDB_EXPERIMENTAL OFF)
|
2020-06-11 05:07:49 +08:00
|
|
|
endif()
|
|
|
|
|
2020-07-06 07:18:08 +08:00
|
|
|
################################################################################
|
|
|
|
# TOML11
|
|
|
|
################################################################################
|
|
|
|
|
2020-07-13 10:43:38 +08:00
|
|
|
# TOML can download and install itself into the binary directory, so it should
|
|
|
|
# always be available.
|
2020-10-23 03:27:06 +08:00
|
|
|
find_package(toml11 QUIET)
|
|
|
|
if(toml11_FOUND)
|
|
|
|
add_library(toml11_target INTERFACE)
|
|
|
|
add_dependencies(toml11_target INTERFACE toml11::toml11)
|
|
|
|
else()
|
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
ExternalProject_add(toml11Project
|
|
|
|
URL "https://github.com/ToruNiina/toml11/archive/v3.4.0.tar.gz"
|
|
|
|
URL_HASH SHA256=bc6d733efd9216af8c119d8ac64a805578c79cc82b813e4d1d880ca128bd154d
|
|
|
|
CMAKE_CACHE_ARGS
|
|
|
|
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/toml11
|
|
|
|
-Dtoml11_BUILD_TEST:BOOL=OFF
|
|
|
|
BUILD_ALWAYS ON)
|
|
|
|
add_library(toml11_target INTERFACE)
|
|
|
|
add_dependencies(toml11_target toml11Project)
|
|
|
|
target_include_directories(toml11_target SYSTEM INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/toml11/include)
|
|
|
|
endif()
|
2020-07-06 07:18:08 +08:00
|
|
|
|
2020-06-11 05:07:49 +08:00
|
|
|
################################################################################
|
|
|
|
|
2019-02-10 14:08:34 +08:00
|
|
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages)
|
|
|
|
add_custom_target(packages)
|
|
|
|
|
2019-02-08 14:18:31 +08:00
|
|
|
function(print_components)
|
2019-02-10 14:08:34 +08:00
|
|
|
message(STATUS "=========================================")
|
2019-02-08 14:18:31 +08:00
|
|
|
message(STATUS " Components Build Overview ")
|
2019-02-10 14:08:34 +08:00
|
|
|
message(STATUS "=========================================")
|
2021-08-05 21:31:15 +08:00
|
|
|
message(STATUS "Build Bindings (depends on Python): ${WITH_PYTHON}")
|
|
|
|
message(STATUS "Build C Bindings: ${WITH_C_BINDING}")
|
|
|
|
message(STATUS "Build Python Bindings: ${WITH_PYTHON_BINDING}")
|
|
|
|
message(STATUS "Build Java Bindings: ${WITH_JAVA_BINDING}")
|
|
|
|
message(STATUS "Build Go bindings: ${WITH_GO_BINDING}")
|
|
|
|
message(STATUS "Build Ruby bindings: ${WITH_RUBY_BINDING}")
|
2019-02-10 14:08:34 +08:00
|
|
|
message(STATUS "Build with TLS support: ${WITH_TLS}")
|
2019-02-15 08:37:48 +08:00
|
|
|
message(STATUS "Build Documentation (make html): ${WITH_DOCUMENTATION}")
|
2021-08-05 21:31:15 +08:00
|
|
|
message(STATUS "Build Python sdist (make package): ${WITH_PYTHON_BINDING}")
|
2020-02-10 00:34:14 +08:00
|
|
|
message(STATUS "Configure CTest (depends on Python): ${WITH_PYTHON}")
|
2020-06-11 05:07:49 +08:00
|
|
|
message(STATUS "Build with RocksDB: ${WITH_ROCKSDB_EXPERIMENTAL}")
|
2019-02-10 14:08:34 +08:00
|
|
|
message(STATUS "=========================================")
|
2019-02-08 14:18:31 +08:00
|
|
|
endfunction()
|
2019-02-12 01:16:40 +08:00
|
|
|
|
|
|
|
if(FORCE_ALL_COMPONENTS)
|
2021-08-05 21:31:15 +08:00
|
|
|
if(NOT WITH_C_BINDING OR NOT WITH_JAVA_BINDING OR NOT WITH_TLS OR NOT WITH_GO_BINDING OR NOT WITH_RUBY_BINDING OR NOT WITH_PYTHON_BINDING OR NOT WITH_DOCUMENTATION)
|
2019-02-12 01:16:40 +08:00
|
|
|
print_components()
|
|
|
|
message(FATAL_ERROR "FORCE_ALL_COMPONENTS is set but not all dependencies could be found")
|
|
|
|
endif()
|
|
|
|
endif()
|