mdbx-cmake: новые настройки cmake-format (косметика).

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2024-12-12 11:20:34 +03:00
parent b687e835e9
commit f2dc60aa53
6 changed files with 308 additions and 652 deletions

3
.cmake-format.yaml Normal file
View File

@ -0,0 +1,3 @@
format:
line_width: 120
tab_size: 2

View File

@ -1,25 +1,20 @@
# Copyright (c) 2020-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
# Copyright (c) 2020-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> ###############################################
# SPDX-License-Identifier: Apache-2.0
#
# Donations are welcome to ETH `0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A`.
# Всё будет хорошо!
# Donations are welcome to ETH `0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A`. Всё будет хорошо!
# libmdbx = { Revised and extended descendant of Symas LMDB. } Please see
# README.md at https://gitflic.ru/project/erthink/libmdbx
# libmdbx = { Revised and extended descendant of Symas LMDB. } Please see README.md at
# https://gitflic.ru/project/erthink/libmdbx
#
# Libmdbx is superior to LMDB in terms of features and reliability, not inferior
# in performance. libmdbx works on Linux, FreeBSD, MacOS X and other systems
# compliant with POSIX.1-2008, but also support Windows as a complementary
# platform.
# Libmdbx is superior to LMDB in terms of features and reliability, not inferior in performance. libmdbx works on Linux,
# FreeBSD, MacOS X and other systems compliant with POSIX.1-2008, but also support Windows as a complementary platform.
#
# The next version is under active non-public development and will be released
# as MithrilDB and libmithrildb for libraries & packages. Admittedly mythical
# Mithril is resembling silver but being stronger and lighter than steel.
# The next version is under active non-public development and will be released as MithrilDB and libmithrildb for
# libraries & packages. Admittedly mythical Mithril is resembling silver but being stronger and lighter than steel.
# Therefore MithrilDB is rightly relevant name.
#
# MithrilDB will be radically different from libmdbx by the new database format
# and API based on C++17, as well as the Apache 2.0 License. The goal of this
# revolution is to provide a clearer and robust API, add more features and new
# MithrilDB will be radically different from libmdbx by the new database format and API based on C++17, as well as the
# Apache 2.0 License. The goal of this revolution is to provide a clearer and robust API, add more features and new
# valuable properties of database.
if(CMAKE_VERSION VERSION_LESS 3.8.2)
@ -190,8 +185,7 @@ else()
message(
FATAL_ERROR
"\nThe set of libmdbx source code files is incomplete! "
"Instead just follow the https://libmdbx.dqdkfa.ru/usage.html "
"PLEASE, AVOID USING ANY OTHER TECHNIQUES.")
"Instead just follow the https://libmdbx.dqdkfa.ru/usage.html " "PLEASE, AVOID USING ANY OTHER TECHNIQUES.")
endif()
# Provide version
@ -199,15 +193,12 @@ include(cmake/utils.cmake)
set(MDBX_BUILD_METADATA
"${MDBX_BUILD_METADATA}"
CACHE STRING "An extra/custom information provided during libmdbx build")
semver_provide(MDBX "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"${MDBX_BUILD_METADATA}" FALSE)
semver_provide(MDBX "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "${MDBX_BUILD_METADATA}" FALSE)
message(STATUS "libmdbx version is ${MDBX_VERSION}")
if(DEFINED PROJECT_NAME)
option(
MDBX_FORCE_BUILD_AS_MAIN_PROJECT
"Force libmdbx to full control build options even it added as a subdirectory to your project."
OFF)
option(MDBX_FORCE_BUILD_AS_MAIN_PROJECT
"Force libmdbx to full control build options even it added as a subdirectory to your project." OFF)
endif()
if(DEFINED PROJECT_NAME AND NOT MDBX_FORCE_BUILD_AS_MAIN_PROJECT)
@ -230,10 +221,7 @@ if(NOT MDBX_AMALGAMATED_SOURCE)
include(CTest)
option(MDBX_ENABLE_TESTS "Build libmdbx tests." ${BUILD_TESTING})
elseif(DEFINED MDBX_ENABLE_TESTS AND MDBX_ENABLE_TESTS)
message(
WARNING
"MDBX_ENABLE_TESTS=${MDBX_ENABLE_TESTS}: But amalgamated source code don't includes tests."
)
message(WARNING "MDBX_ENABLE_TESTS=${MDBX_ENABLE_TESTS}: But amalgamated source code don't includes tests.")
set(MDBX_ENABLE_TESTS OFF)
endif()
@ -242,8 +230,7 @@ if(NOT CMAKE_CXX_COMPILER_LOADED)
include(CheckLanguage)
if(NOT DEFINED MDBX_BUILD_CXX
OR MDBX_BUILD_CXX
OR (NOT MDBX_AMALGAMATED_SOURCE AND (NOT DEFINED MDBX_ENABLE_TESTS
OR MDBX_ENABLE_TESTS)))
OR (NOT MDBX_AMALGAMATED_SOURCE AND (NOT DEFINED MDBX_ENABLE_TESTS OR MDBX_ENABLE_TESTS)))
check_language(CXX)
if(CMAKE_CXX_COMPILER)
enable_language(CXX)
@ -257,10 +244,7 @@ endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Release
CACHE
STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
@ -303,10 +287,8 @@ include(GNUInstallDirs)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION LESS 1900)
message(
SEND_ERROR
"MSVC compiler ${MSVC_VERSION} is too old for building MDBX."
" At least \"Microsoft C/C++ Compiler\" version 19.0.24234.1 (Visual Studio 2015 Update 3) is required."
)
SEND_ERROR "MSVC compiler ${MSVC_VERSION} is too old for building MDBX."
" At least \"Microsoft C/C++ Compiler\" version 19.0.24234.1 (Visual Studio 2015 Update 3) is required.")
endif()
if(NOT DEFINED THREADS_PREFER_PTHREAD_FLAG)
@ -350,38 +332,29 @@ if(SUBPROJECT)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" OFF)
endif()
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
option(CMAKE_POSITION_INDEPENDENT_CODE
"Generate position independent (PIC)" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON)
endif()
set(MDBX_MANAGE_BUILD_FLAGS_DEFAULT OFF)
else()
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)"
ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "Generate position independent (PIC)" ON)
if(CC_HAS_ARCH_NATIVE)
option(BUILD_FOR_NATIVE_CPU "Generate code for the compiling machine CPU"
OFF)
option(BUILD_FOR_NATIVE_CPU "Generate code for the compiling machine CPU" OFF)
endif()
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION_AVAILABLE
OR GCC_LTO_AVAILABLE
OR MSVC_LTO_AVAILABLE
OR CLANG_LTO_AVAILABLE)
if((CMAKE_CONFIGURATION_TYPES OR NOT CMAKE_BUILD_TYPE_UPPERCASE STREQUAL
"DEBUG")
AND ((MSVC_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19
)
OR (GCC_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS
7)
OR (CLANG_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION
VERSION_LESS 5)
))
if((CMAKE_CONFIGURATION_TYPES OR NOT CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG")
AND ((MSVC_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19)
OR (GCC_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7)
OR (CLANG_LTO_AVAILABLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5)))
set(INTERPROCEDURAL_OPTIMIZATION_DEFAULT ON)
else()
set(INTERPROCEDURAL_OPTIMIZATION_DEFAULT OFF)
endif()
option(INTERPROCEDURAL_OPTIMIZATION
"Enable interprocedural/LTO optimization."
option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural/LTO optimization."
${INTERPROCEDURAL_OPTIMIZATION_DEFAULT})
endif()
@ -457,8 +430,8 @@ else()
if(NOT MDBX_AMALGAMATED_SOURCE)
find_program(VALGRIND valgrind)
if(VALGRIND)
# (LY) cmake is ugly and nasty. Therefore memcheck-options should be
# defined before including ctest. Otherwise ctest may ignore it.
# (LY) cmake is ugly and nasty. Therefore memcheck-options should be defined before including ctest. Otherwise
# ctest may ignore it.
set(MEMORYCHECK_SUPPRESSIONS_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/test/valgrind_suppress.txt"
CACHE FILEPATH "Suppressions file for Valgrind" FORCE)
@ -483,19 +456,15 @@ else()
if(UNIX)
find_program(CLANG_FORMAT NAMES clang-format-13 clang-format)
if(CLANG_FORMAT)
execute_process(COMMAND ${CLANG_FORMAT} "--version"
OUTPUT_VARIABLE clang_format_version_info)
string(REGEX MATCH "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?"
clang_format_version_info CLANG_FORMAT_VERSION)
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS
13.0)
execute_process(COMMAND ${CLANG_FORMAT} "--version" OUTPUT_VARIABLE clang_format_version_info)
string(REGEX MATCH "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" clang_format_version_info CLANG_FORMAT_VERSION)
if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 13.0)
# Enable 'make reformat' target.
add_custom_target(
reformat
VERBATIM
COMMAND
git ls-files | grep -E \\.\(c|cxx|cc|cpp|h|hxx|hpp\)\(\\.in\)?\$ |
xargs ${CLANG_FORMAT} -i --style=file
COMMAND git ls-files | grep -E \\.\(c|cxx|cc|cpp|h|hxx|hpp\)\(\\.in\)?\$ | xargs ${CLANG_FORMAT} -i
--style=file
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
endif()
@ -523,8 +492,7 @@ else()
set(MDBX_MANAGE_BUILD_FLAGS_DEFAULT ON)
endif(SUBPROJECT)
option(MDBX_MANAGE_BUILD_FLAGS
"Allow libmdbx to configure/manage/override its own build flags"
option(MDBX_MANAGE_BUILD_FLAGS "Allow libmdbx to configure/manage/override its own build flags"
${MDBX_MANAGE_BUILD_FLAGS_DEFAULT})
if(MDBX_MANAGE_BUILD_FLAGS)
setup_compile_flags()
@ -541,17 +509,11 @@ if(NOT DEFINED MDBX_CXX_STANDARD)
endif()
if(DEFINED CMAKE_CXX_STANDARD)
set(MDBX_CXX_STANDARD ${CMAKE_CXX_STANDARD})
elseif(NOT HAS_CXX23 LESS 0
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 12))
elseif(NOT HAS_CXX23 LESS 0 AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12))
set(MDBX_CXX_STANDARD 23)
elseif(NOT HAS_CXX20 LESS 0
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 10))
elseif(NOT HAS_CXX20 LESS 0 AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))
set(MDBX_CXX_STANDARD 20)
elseif(NOT HAS_CXX17 LESS 0
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 5))
elseif(NOT HAS_CXX17 LESS 0 AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5))
set(MDBX_CXX_STANDARD 17)
elseif(NOT HAS_CXX14 LESS 0)
set(MDBX_CXX_STANDARD 14)
@ -574,8 +536,7 @@ if(NOT DEFINED MDBX_C_STANDARD)
set(MDBX_C_STANDARD ${CMAKE_C_STANDARD})
elseif(
MSVC
# MSVC >= 19.28 (Microsoft Visual Studio 16.8) is mad! It unable process
# Windows SDK headers in the C11 mode!
# MSVC >= 19.28 (Microsoft Visual Studio 16.8) is mad! It unable process Windows SDK headers in the C11 mode!
AND MSVC_VERSION GREATER 1927
AND NOT MSVC_VERSION GREATER 1929)
set(MDBX_C_STANDARD 99)
@ -603,16 +564,13 @@ if(WIN32 AND EXISTS "${MDBX_SOURCE_DIR}/ntdll.def")
endif()
if(MSVC_LIB_EXE)
message(STATUS "Found MSVC's lib tool: ${MSVC_LIB_EXE}")
set(MDBX_NTDLL_EXTRA_IMPLIB
"${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib")
set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib")
add_custom_command(
OUTPUT "${MDBX_NTDLL_EXTRA_IMPLIB}"
COMMENT "Create extra-import-library for ntdll.dll"
MAIN_DEPENDENCY "${MDBX_SOURCE_DIR}/ntdll.def"
COMMAND
${MSVC_LIB_EXE} /def:"${MDBX_SOURCE_DIR}/ntdll.def"
/out:"${MDBX_NTDLL_EXTRA_IMPLIB}"
${INITIAL_CMAKE_STATIC_LINKER_FLAGS})
COMMAND ${MSVC_LIB_EXE} /def:"${MDBX_SOURCE_DIR}/ntdll.def" /out:"${MDBX_NTDLL_EXTRA_IMPLIB}"
${INITIAL_CMAKE_STATIC_LINKER_FLAGS})
else()
message(WARNING "MSVC's lib tool not found")
endif()
@ -625,14 +583,12 @@ if(WIN32 AND EXISTS "${MDBX_SOURCE_DIR}/ntdll.def")
endif()
if(DLLTOOL)
message(STATUS "Found dlltool: ${DLLTOOL}")
set(MDBX_NTDLL_EXTRA_IMPLIB
"${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a")
set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a")
add_custom_command(
OUTPUT "${MDBX_NTDLL_EXTRA_IMPLIB}"
COMMENT "Create extra-import-library for ntdll.dll"
MAIN_DEPENDENCY "${MDBX_SOURCE_DIR}/ntdll.def"
COMMAND ${DLLTOOL} -d "${MDBX_SOURCE_DIR}/ntdll.def" -l
"${MDBX_NTDLL_EXTRA_IMPLIB}")
COMMAND ${DLLTOOL} -d "${MDBX_SOURCE_DIR}/ntdll.def" -l "${MDBX_NTDLL_EXTRA_IMPLIB}")
else()
message(WARNING "dlltool not found")
endif()
@ -647,12 +603,11 @@ if(WIN32 AND EXISTS "${MDBX_SOURCE_DIR}/ntdll.def")
add_library(ntdll_extra STATIC IMPORTED GLOBAL)
add_dependencies(ntdll_extra ntdll_extra_target)
# (3) specify where the library is (and where to find the headers)
set_target_properties(ntdll_extra PROPERTIES IMPORTED_LOCATION
"${MDBX_NTDLL_EXTRA_IMPLIB}")
set_target_properties(ntdll_extra PROPERTIES IMPORTED_LOCATION "${MDBX_NTDLL_EXTRA_IMPLIB}")
endif()
endif()
# ##############################################################################
# ######################################################################################################################
# ~~~
#
# #### ##### ##### # #### # # ####
@ -663,10 +618,9 @@ endif()
# #### # # # #### # # ####
#
# ~~~
# ##############################################################################
# ######################################################################################################################
set(MDBX_BUILD_OPTIONS ENABLE_UBSAN ENABLE_ASAN ENABLE_MEMCHECK ENABLE_GPROF
ENABLE_GCOV)
set(MDBX_BUILD_OPTIONS ENABLE_UBSAN ENABLE_ASAN ENABLE_MEMCHECK ENABLE_GPROF ENABLE_GCOV)
macro(add_mdbx_option NAME DESCRIPTION DEFAULT)
list(APPEND MDBX_BUILD_OPTIONS ${NAME})
if(NOT ${DEFAULT} STREQUAL "AUTO")
@ -686,51 +640,32 @@ else()
set(MDBX_BUILD_TOOLS_DEFAULT ON)
endif()
add_mdbx_option(MDBX_INSTALL_STATIC
"Build and install libmdbx for static linking" OFF)
add_mdbx_option(MDBX_BUILD_SHARED_LIBRARY
"Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
add_mdbx_option(
MDBX_BUILD_TOOLS "Build MDBX tools (mdbx_chk/stat/dump/load/copy/drop)"
${MDBX_BUILD_TOOLS_DEFAULT})
cmake_dependent_option(
MDBX_INSTALL_MANPAGES
"Install man-pages for MDBX tools (mdbx_chk/stat/dump/load/copy)" ON
MDBX_BUILD_TOOLS OFF)
add_mdbx_option(
MDBX_TXN_CHECKOWNER
"Checking transaction matches the calling thread inside libmdbx's API" ON)
add_mdbx_option(
MDBX_ENV_CHECKPID
"Checking PID inside libmdbx's API against reuse DB environment after the fork()"
AUTO)
add_mdbx_option(MDBX_INSTALL_STATIC "Build and install libmdbx for static linking" OFF)
add_mdbx_option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
add_mdbx_option(MDBX_BUILD_TOOLS "Build MDBX tools (mdbx_chk/stat/dump/load/copy/drop)" ${MDBX_BUILD_TOOLS_DEFAULT})
cmake_dependent_option(MDBX_INSTALL_MANPAGES "Install man-pages for MDBX tools (mdbx_chk/stat/dump/load/copy)" ON
MDBX_BUILD_TOOLS OFF)
add_mdbx_option(MDBX_TXN_CHECKOWNER "Checking transaction matches the calling thread inside libmdbx's API" ON)
add_mdbx_option(MDBX_ENV_CHECKPID "Checking PID inside libmdbx's API against reuse DB environment after the fork()"
AUTO)
mark_as_advanced(MDBX_ENV_CHECKPID)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_mdbx_option(MDBX_DISABLE_GNU_SOURCE "Don't use GNU/Linux libc extensions"
OFF)
add_mdbx_option(MDBX_DISABLE_GNU_SOURCE "Don't use GNU/Linux libc extensions" OFF)
mark_as_advanced(MDBX_DISABLE_GNU_SOURCE)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR IOS)
add_mdbx_option(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY
"Disable use fcntl(F_FULLFSYNC) in favor of speed" OFF)
add_mdbx_option(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY "Disable use fcntl(F_FULLFSYNC) in favor of speed" OFF)
mark_as_advanced(MDBX_APPLE_SPEED_INSTEADOF_DURABILITY)
endif()
if(WIN32)
if(MDBX_NTDLL_EXTRA_IMPLIB)
add_mdbx_option(
MDBX_WITHOUT_MSVC_CRT
"Avoid dependence from MSVC CRT and use ntdll.dll instead" OFF)
add_mdbx_option(MDBX_WITHOUT_MSVC_CRT "Avoid dependence from MSVC CRT and use ntdll.dll instead" OFF)
endif()
set(MDBX_AVOID_MSYNC_DEFAULT ON)
else()
add_mdbx_option(
MDBX_USE_OFDLOCKS
"Use Open file description locks (aka OFD locks, non-POSIX)" AUTO)
add_mdbx_option(MDBX_USE_OFDLOCKS "Use Open file description locks (aka OFD locks, non-POSIX)" AUTO)
mark_as_advanced(MDBX_USE_OFDLOCKS)
add_mdbx_option(
MDBX_USE_MINCORE
"Use Unix' mincore() to determine whether DB-pages are resident in memory"
ON)
add_mdbx_option(MDBX_USE_MINCORE "Use Unix' mincore() to determine whether DB-pages are resident in memory" ON)
mark_as_advanced(MDBX_USE_MINCORE)
set(MDBX_AVOID_MSYNC_DEFAULT OFF)
endif()
@ -738,19 +673,12 @@ add_mdbx_option(
MDBX_AVOID_MSYNC
"Disable in-memory database updating with consequent flush-to-disk/msync syscall in `MDBX_WRITEMAP` mode"
${MDBX_AVOID_MSYNC_DEFAULT})
add_mdbx_option(
MDBX_MMAP_NEEDS_JOLT
"Assume system needs explicit syscall to sync/flush/write modified mapped memory"
AUTO)
add_mdbx_option(MDBX_MMAP_NEEDS_JOLT "Assume system needs explicit syscall to sync/flush/write modified mapped memory"
AUTO)
mark_as_advanced(MDBX_MMAP_NEEDS_JOLT)
add_mdbx_option(
MDBX_LOCKING
"Locking method (Windows=-1, SystemV=5, POSIX=1988, POSIX=2001, POSIX=2008)"
AUTO)
add_mdbx_option(MDBX_LOCKING "Locking method (Windows=-1, SystemV=5, POSIX=1988, POSIX=2001, POSIX=2008)" AUTO)
mark_as_advanced(MDBX_LOCKING)
add_mdbx_option(
MDBX_TRUST_RTC
"Does a system have battery-backed Real-Time Clock or just a fake" AUTO)
add_mdbx_option(MDBX_TRUST_RTC "Does a system have battery-backed Real-Time Clock or just a fake" AUTO)
mark_as_advanced(MDBX_TRUST_RTC)
add_mdbx_option(MDBX_FORCE_ASSERTIONS "Force enable assertion checking" OFF)
add_mdbx_option(
@ -758,24 +686,18 @@ add_mdbx_option(
"Disable some checks to reduce an overhead and detection probability of database corruption to a values closer to the LMDB"
OFF)
mark_as_advanced(MDBX_DISABLE_VALIDATION)
add_mdbx_option(MDBX_ENABLE_REFUND
"Zerocost auto-compactification during write-transactions" ON)
add_mdbx_option(MDBX_ENABLE_REFUND "Zerocost auto-compactification during write-transactions" ON)
add_mdbx_option(
MDBX_ENABLE_BIGFOOT
"Chunking long list of retired pages during huge transactions commit to avoid use sequences of pages"
ON)
add_mdbx_option(MDBX_ENABLE_PGOP_STAT
"Gathering statistics for page operations" ON)
"Chunking long list of retired pages during huge transactions commit to avoid use sequences of pages" ON)
add_mdbx_option(MDBX_ENABLE_PGOP_STAT "Gathering statistics for page operations" ON)
add_mdbx_option(MDBX_ENABLE_PROFGC "Profiling of GC search and updates" OFF)
mark_as_advanced(MDBX_ENABLE_PROFGC)
add_mdbx_option(
MDBX_ENABLE_DBI_SPARSE
"Support for sparse sets of DBI handles to reduce overhead when starting and processing transactions"
ON)
add_mdbx_option(
MDBX_ENABLE_DBI_LOCKFREE
"Support for deferred releasing and a lockfree path to quickly open DBI handles"
ON)
"Support for sparse sets of DBI handles to reduce overhead when starting and processing transactions" ON)
add_mdbx_option(MDBX_ENABLE_DBI_LOCKFREE
"Support for deferred releasing and a lockfree path to quickly open DBI handles" ON)
if(NOT MDBX_AMALGAMATED_SOURCE)
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE_UPPERCASE STREQUAL "DEBUG")
@ -783,14 +705,11 @@ if(NOT MDBX_AMALGAMATED_SOURCE)
else()
set(MDBX_ALLOY_BUILD_DEFAULT ON)
endif()
add_mdbx_option(
MDBX_ALLOY_BUILD "Build MDBX library through single/alloyed object file"
${MDBX_ALLOY_BUILD_DEFAULT})
add_mdbx_option(MDBX_ALLOY_BUILD "Build MDBX library through single/alloyed object file" ${MDBX_ALLOY_BUILD_DEFAULT})
endif()
if((MDBX_BUILD_TOOLS OR MDBX_ENABLE_TESTS) AND MDBX_BUILD_SHARED_LIBRARY)
add_mdbx_option(MDBX_LINK_TOOLS_NONSTATIC
"Link MDBX tools with non-static libmdbx" OFF)
add_mdbx_option(MDBX_LINK_TOOLS_NONSTATIC "Link MDBX tools with non-static libmdbx" OFF)
else()
unset(MDBX_LINK_TOOLS_NONSTATIC CACHE)
endif()
@ -802,10 +721,8 @@ if(CMAKE_CXX_COMPILER_LOADED
option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING})
endif()
if(NOT MDBX_WITHOUT_MSVC_CRT
AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 4.8)
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 3.9)
AND NOT (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9)
AND NOT (MSVC AND MSVC_VERSION LESS 1900))
option(MDBX_BUILD_CXX "Build C++ portion" ON)
else()
@ -820,13 +737,10 @@ if(CI)
add_definitions(-DMDBX_CI="${CI}")
endif()
# ##############################################################################
# ######################################################################################################################
if(MDBX_BUILD_CXX AND NOT CMAKE_CXX_COMPILER_LOADED)
message(
FATAL_ERROR
"MDBX_BUILD_CXX=${MDBX_BUILD_CXX}: The C++ compiler is required to build the C++API."
)
message(FATAL_ERROR "MDBX_BUILD_CXX=${MDBX_BUILD_CXX}: The C++ compiler is required to build the C++API.")
endif()
if(MDBX_BUILD_CXX)
@ -841,8 +755,7 @@ if(MDBX_AMALGAMATED_SOURCE)
list(APPEND LIBMDBX_SOURCES mdbx.c)
else()
# generate version file
configure_file("${MDBX_SOURCE_DIR}/version.c.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.c" ESCAPE_QUOTES)
configure_file("${MDBX_SOURCE_DIR}/version.c.in" "${CMAKE_CURRENT_BINARY_DIR}/version.c" ESCAPE_QUOTES)
file(SHA256 "${CMAKE_CURRENT_BINARY_DIR}/version.c" MDBX_SOURCERY_DIGEST)
string(MAKE_C_IDENTIFIER "${MDBX_GIT_DESCRIBE}" MDBX_SOURCERY_SUFFIX)
set(MDBX_BUILD_SOURCERY "${MDBX_SOURCERY_DIGEST}_${MDBX_SOURCERY_SUFFIX}")
@ -930,21 +843,18 @@ else()
list(APPEND LIBMDBX_SOURCES "${MDBX_SOURCE_DIR}/lck-posix.c")
endif()
if(NOT APPLE)
list(APPEND LIBMDBX_SOURCES "${MDBX_SOURCE_DIR}/windows-import.h"
"${MDBX_SOURCE_DIR}/windows-import.c"
list(APPEND LIBMDBX_SOURCES "${MDBX_SOURCE_DIR}/windows-import.h" "${MDBX_SOURCE_DIR}/windows-import.c"
"${MDBX_SOURCE_DIR}/lck-windows.c")
endif()
include_directories("${MDBX_SOURCE_DIR}")
endif()
endif(MDBX_AMALGAMATED_SOURCE)
if(MDBX_BUILD_CXX)
message(
STATUS "Use C${MDBX_C_STANDARD} and C++${MDBX_CXX_STANDARD} for libmdbx")
message(STATUS "Use C${MDBX_C_STANDARD} and C++${MDBX_CXX_STANDARD} for libmdbx")
list(APPEND LIBMDBX_PUBLIC_HEADERS mdbx.h++)
list(APPEND LIBMDBX_SOURCES "${MDBX_SOURCE_DIR}/mdbx.c++" mdbx.h++)
else()
message(
STATUS "Use C${MDBX_C_STANDARD} for libmdbx but C++ portion is disabled")
message(STATUS "Use C${MDBX_C_STANDARD} for libmdbx but C++ portion is disabled")
endif()
if(MSVC)
@ -953,26 +863,20 @@ endif()
macro(target_setup_options TARGET)
if(DEFINED INTERPROCEDURAL_OPTIMIZATION)
set_target_properties(
${TARGET} PROPERTIES INTERPROCEDURAL_OPTIMIZATION
$<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
set_target_properties(${TARGET} PROPERTIES INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
endif()
if(NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11)
set_target_properties(${TARGET} PROPERTIES C_STANDARD ${MDBX_C_STANDARD}
C_STANDARD_REQUIRED ON)
set_target_properties(${TARGET} PROPERTIES C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON)
endif()
if(MDBX_BUILD_CXX)
if(NOT CXX_FALLBACK_GNU11 AND NOT CXX_FALLBACK_11)
set_target_properties(
${TARGET} PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON)
set_target_properties(${TARGET} PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
endif()
if(MSVC AND NOT MSVC_VERSION LESS 1910)
target_compile_options(${TARGET} INTERFACE "/Zc:__cplusplus")
endif()
endif()
if(CC_HAS_FASTMATH AND NOT (CMAKE_COMPILER_IS_CLANG
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))
if(CC_HAS_FASTMATH AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))
target_compile_options(${TARGET} PRIVATE "-ffast-math")
endif()
if(CC_HAS_VISIBILITY)
@ -1001,8 +905,7 @@ macro(libmdbx_setup_libs TARGET MODE)
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_WITHOUT_MSVC_CRT)
target_link_libraries(${TARGET} ${MODE} ntdll_extra)
endif()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL
"Solaris")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris")
target_link_libraries(${TARGET} ${MODE} kstat)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(${TARGET} ${MODE} log)
@ -1023,8 +926,7 @@ if(MDBX_INSTALL_STATIC)
else()
add_library(mdbx-static STATIC EXCLUDE_FROM_ALL ${LIBMDBX_SOURCES})
endif()
set_target_properties(mdbx-static PROPERTIES PUBLIC_HEADER
"${LIBMDBX_PUBLIC_HEADERS}")
set_target_properties(mdbx-static PROPERTIES PUBLIC_HEADER "${LIBMDBX_PUBLIC_HEADERS}")
target_compile_definitions(mdbx-static PRIVATE MDBX_BUILD_SHARED_LIBRARY=0)
target_setup_options(mdbx-static)
libmdbx_setup_libs(mdbx-static INTERFACE)
@ -1035,13 +937,12 @@ else()
endif()
target_include_directories(mdbx-static INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
# ##############################################################################
# ######################################################################################################################
# build shared library
if(MDBX_BUILD_SHARED_LIBRARY)
add_library(mdbx SHARED ${LIBMDBX_SOURCES})
set_target_properties(mdbx PROPERTIES PUBLIC_HEADER
"${LIBMDBX_PUBLIC_HEADERS}")
set_target_properties(mdbx PROPERTIES PUBLIC_HEADER "${LIBMDBX_PUBLIC_HEADERS}")
target_compile_definitions(
mdbx
PRIVATE LIBMDBX_EXPORTS MDBX_BUILD_SHARED_LIBRARY=1
@ -1052,9 +953,7 @@ if(MDBX_BUILD_SHARED_LIBRARY)
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_WITHOUT_MSVC_CRT)
set_property(TARGET mdbx PROPERTY LINKER_FLAGS "/NODEFAULTLIB")
else()
set_property(
TARGET mdbx PROPERTY MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set_property(TARGET mdbx PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
endif()
if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION))
@ -1070,18 +969,15 @@ if(MDBX_BUILD_SHARED_LIBRARY AND MDBX_LINK_TOOLS_NONSTATIC)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already (but later on when
# installing)
# when building, don't use the install RPATH already (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# add the automatically determined parts of the RPATH which point to
# directories outside the build tree to the install RPATH
# add the automatically determined parts of the RPATH which point to directories outside the build tree to the install
# RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system
# directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if(isSystemDir EQUAL -1)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
@ -1091,8 +987,7 @@ if(MDBX_BUILD_SHARED_LIBRARY AND MDBX_LINK_TOOLS_NONSTATIC)
endif()
if(WIN32)
# Windows don't have RPATH feature, therefore we should prepare PATH or copy
# DLL(s)
# Windows don't have RPATH feature, therefore we should prepare PATH or copy DLL(s)
set(TOOL_MDBX_DLLCRUTCH "Crutch for ${CMAKE_SYSTEM_NAME}")
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_VERSION VERSION_LESS 3.0)
# will use LOCATION property to compose DLLPATH
@ -1110,21 +1005,17 @@ endif()
if(MDBX_BUILD_TOOLS)
set(WINGETOPT_SRC "")
if(WIN32)
set(WINGETOPT_SRC ${MDBX_SOURCE_DIR}/tools/wingetopt.c
${MDBX_SOURCE_DIR}/tools/wingetopt.h)
set(WINGETOPT_SRC ${MDBX_SOURCE_DIR}/tools/wingetopt.c ${MDBX_SOURCE_DIR}/tools/wingetopt.h)
endif()
foreach(TOOL chk copy stat dump load drop)
if(MDBX_AMALGAMATED_SOURCE)
add_executable(mdbx_${TOOL} mdbx.h ${MDBX_SOURCE_DIR}/mdbx_${TOOL}.c)
else()
add_executable(mdbx_${TOOL} mdbx.h ${MDBX_SOURCE_DIR}/tools/${TOOL}.c
${WINGETOPT_SRC})
add_executable(mdbx_${TOOL} mdbx.h ${MDBX_SOURCE_DIR}/tools/${TOOL}.c ${WINGETOPT_SRC})
endif()
if(NOT C_FALLBACK_GNU11 AND NOT C_FALLBACK_11)
set_target_properties(
mdbx_${TOOL} PROPERTIES C_STANDARD ${MDBX_C_STANDARD}
C_STANDARD_REQUIRED ON)
set_target_properties(mdbx_${TOOL} PROPERTIES C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON)
endif()
target_setup_options(mdbx_${TOOL})
target_link_libraries(mdbx_${TOOL} ${TOOL_MDBX_LIB})
@ -1135,7 +1026,7 @@ if(MDBX_BUILD_TOOLS)
endif()
endif()
# ##############################################################################
# ######################################################################################################################
# mdbx-shared-lib installation
if(NOT DEFINED MDBX_DLL_INSTALL_DESTINATION)
@ -1178,19 +1069,15 @@ if(MDBX_BUILD_TOOLS)
set(MDBX_TOOLS_INSTALL_DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS mdbx_chk mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_drop
RUNTIME DESTINATION ${MDBX_TOOLS_INSTALL_DESTINATION}
COMPONENT runtime)
RUNTIME DESTINATION ${MDBX_TOOLS_INSTALL_DESTINATION} COMPONENT runtime)
if(MDBX_INSTALL_MANPAGES)
if(NOT DEFINED MDBX_MAN_INSTALL_DESTINATION)
set(MDBX_MAN_INSTALL_DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
install(
FILES "${MDBX_SOURCE_DIR}/man1/mdbx_chk.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_stat.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_copy.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_dump.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_load.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_drop.1"
FILES "${MDBX_SOURCE_DIR}/man1/mdbx_chk.1" "${MDBX_SOURCE_DIR}/man1/mdbx_stat.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_copy.1" "${MDBX_SOURCE_DIR}/man1/mdbx_dump.1"
"${MDBX_SOURCE_DIR}/man1/mdbx_load.1" "${MDBX_SOURCE_DIR}/man1/mdbx_drop.1"
DESTINATION ${MDBX_MAN_INSTALL_DESTINATION}
COMPONENT doc)
endif()
@ -1225,7 +1112,7 @@ if(MDBX_INSTALL_STATIC)
endif()
endif(MDBX_INSTALL_STATIC)
# ##############################################################################
# ######################################################################################################################
# collect options & build info
if(NOT DEFINED MDBX_BUILD_TIMESTAMP)
@ -1244,8 +1131,7 @@ endif()
if(NOT CMAKE_CONFIGURATION_TYPES)
list(APPEND MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}})
if(MDBX_BUILD_CXX)
list(APPEND MDBX_BUILD_FLAGS
${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}})
list(APPEND MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}})
endif()
endif()
@ -1272,9 +1158,7 @@ list(REMOVE_DUPLICATES MDBX_BUILD_FLAGS)
string(REPLACE ";" " " MDBX_BUILD_FLAGS "${MDBX_BUILD_FLAGS}")
if(CMAKE_CONFIGURATION_TYPES)
# add dynamic part via per-configuration define
message(
STATUS
"MDBX Compile Flags: ${MDBX_BUILD_FLAGS} <AND CONFIGURATION DEPENDENT>")
message(STATUS "MDBX Compile Flags: ${MDBX_BUILD_FLAGS} <AND CONFIGURATION DEPENDENT>")
add_definitions(
-DMDBX_BUILD_FLAGS_CONFIG="$<$<CONFIG:Debug>:${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_DEFINES_DEBUG}>$<$<CONFIG:Release>:${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_DEFINES_RELEASE}>$<$<CONFIG:RelWithDebInfo>:${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CMAKE_C_DEFINES_RELWITHDEBINFO}>$<$<CONFIG:MinSizeRel>:${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_DEFINES_MINSIZEREL}>"
)
@ -1289,8 +1173,7 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
RESULT_VARIABLE rc)
if(rc OR NOT MDBX_BUILD_COMPILER)
string(STRIP "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}"
MDBX_BUILD_COMPILER)
string(STRIP "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}" MDBX_BUILD_COMPILER)
endif()
# make a build-target triplet
@ -1299,8 +1182,7 @@ if(CMAKE_C_COMPILER_TARGET)
else()
if(CMAKE_C_COMPILER_ARCHITECTURE_ID)
string(STRIP "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MDBX_BUILD_TARGET)
elseif(CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL
CMAKE_SYSTEM_NAME)
elseif(CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL CMAKE_SYSTEM_NAME)
string(STRIP "${CMAKE_GENERATOR_PLATFORM}" MDBX_BUILD_TARGET)
elseif(CMAKE_SYSTEM_ARCH)
string(STRIP "${CMAKE_SYSTEM_ARCH}" MDBX_BUILD_TARGET)
@ -1311,20 +1193,16 @@ else()
else()
set(MDBX_BUILD_TARGET "unknown")
endif()
if(CMAKE_C_COMPILER_ABI
AND NOT (CMAKE_C_COMPILER_ABI MATCHES ".*${MDBX_BUILD_TARGET}.*"
OR MDBX_BUILD_TARGET MATCHES ".*${CMAKE_C_COMPILER_ABI}.*"))
string(CONCAT MDBX_BUILD_TARGET
"${MDBX_BUILD_TARGET}-${CMAKE_C_COMPILER_ABI}")
if(CMAKE_C_COMPILER_ABI AND NOT (CMAKE_C_COMPILER_ABI MATCHES ".*${MDBX_BUILD_TARGET}.*"
OR MDBX_BUILD_TARGET MATCHES ".*${CMAKE_C_COMPILER_ABI}.*"))
string(CONCAT MDBX_BUILD_TARGET "${MDBX_BUILD_TARGET}-${CMAKE_C_COMPILER_ABI}")
endif()
if(CMAKE_C_PLATFORM_ID
AND NOT (CMAKE_SYSTEM_NAME
AND (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_SYSTEM_NAME}.*"
OR CMAKE_SYSTEM_NAME MATCHES ".*${CMAKE_C_PLATFORM_ID}.*"))
AND NOT (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_C_PLATFORM_ID}.*"
OR MDBX_BUILD_TARGET MATCHES ".*${CMAKE_C_PLATFORM_ID}.*"))
string(CONCAT MDBX_BUILD_TARGET
"${MDBX_BUILD_TARGET}-${CMAKE_C_COMPILER_ABI}")
AND NOT (CMAKE_SYSTEM_NAME AND (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_SYSTEM_NAME}.*"
OR CMAKE_SYSTEM_NAME MATCHES ".*${CMAKE_C_PLATFORM_ID}.*"))
AND NOT (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_C_PLATFORM_ID}.*" OR MDBX_BUILD_TARGET MATCHES
".*${CMAKE_C_PLATFORM_ID}.*"))
string(CONCAT MDBX_BUILD_TARGET "${MDBX_BUILD_TARGET}-${CMAKE_C_COMPILER_ABI}")
endif()
if(CMAKE_SYSTEM_NAME)
string(CONCAT MDBX_BUILD_TARGET "${MDBX_BUILD_TARGET}-${CMAKE_SYSTEM_NAME}")
@ -1341,8 +1219,7 @@ else()
endif()
# options
set(options VERSION C_COMPILER CXX_COMPILER MDBX_BUILD_TARGET MDBX_BUILD_TYPE
${MDBX_BUILD_OPTIONS})
set(options VERSION C_COMPILER CXX_COMPILER MDBX_BUILD_TARGET MDBX_BUILD_TYPE ${MDBX_BUILD_OPTIONS})
foreach(item IN LISTS options)
if(DEFINED ${item})
set(value "${${item}}")
@ -1359,23 +1236,19 @@ foreach(item IN LISTS options)
endforeach(item)
# provide config.h for library build info
configure_file("${MDBX_SOURCE_DIR}/config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h" ESCAPE_QUOTES)
configure_file("${MDBX_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" ESCAPE_QUOTES)
add_definitions(-DMDBX_CONFIG_H="${CMAKE_CURRENT_BINARY_DIR}/config.h")
# ##############################################################################
# ######################################################################################################################
if(NOT MDBX_AMALGAMATED_SOURCE AND MDBX_ENABLE_TESTS)
if(NOT CMAKE_CXX_COMPILER_LOADED)
message(
FATAL_ERROR
"MDBX_ENABLE_TESTS=${MDBX_ENABLE_TESTS}: The C++ compiler is required to build the tests."
)
message(FATAL_ERROR "MDBX_ENABLE_TESTS=${MDBX_ENABLE_TESTS}: The C++ compiler is required to build the tests.")
endif()
add_subdirectory(test)
endif()
# ##############################################################################
# ######################################################################################################################
if(NOT SUBPROJECT)
set(PACKAGE "libmdbx")

View File

@ -1,4 +1,4 @@
# Copyright (c) 2010-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
# Copyright (c) 2010-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> ###############################################
# SPDX-License-Identifier: Apache-2.0
if(CMAKE_VERSION VERSION_LESS 3.8.2)
@ -32,11 +32,8 @@ if(NOT CMAKE_VERSION VERSION_LESS 3.9)
endif()
if(CMAKE_VERSION MATCHES ".*MSVC.*" AND CMAKE_VERSION VERSION_LESS 3.16)
message(
FATAL_ERROR
"CMake from MSVC kit is unfit! "
"Please use MSVC2019 with modern CMake the original CMake from https://cmake.org/download/"
)
message(FATAL_ERROR "CMake from MSVC kit is unfit! "
"Please use MSVC2019 with modern CMake the original CMake from https://cmake.org/download/")
endif()
if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
@ -62,8 +59,7 @@ if(CMAKE_C_COMPILER_LOADED
AND CMAKE_CXX_COMPILER_LOADED
AND NOT (CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID))
message(WARNING "CMAKE_C_COMPILER_ID (${CMAKE_C_COMPILER_ID}) is different "
"from CMAKE_CXX_COMPILER_ID (${CMAKE_CXX_COMPILER_ID}). "
"The final binary may be unusable.")
"from CMAKE_CXX_COMPILER_ID (${CMAKE_CXX_COMPILER_ID}). " "The final binary may be unusable.")
endif()
if(CMAKE_CXX_COMPILER_LOADED)
@ -80,15 +76,12 @@ macro(check_compiler_flag flag variable)
endif()
endmacro(check_compiler_flag)
# We support building with Clang and gcc. First check what we're using for
# build.
if(CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER_ID MATCHES
".*[Cc][Ll][Aa][Nn][Gg].*")
# We support building with Clang and gcc. First check what we're using for build.
if(CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER_ID MATCHES ".*[Cc][Ll][Aa][Nn][Gg].*")
set(CMAKE_COMPILER_IS_CLANG ON)
set(CMAKE_COMPILER_IS_GNUCC OFF)
endif()
if(CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID MATCHES
".*[Cc][Ll][Aa][Nn][Gg].*")
if(CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ID MATCHES ".*[Cc][Ll][Aa][Nn][Gg].*")
set(CMAKE_COMPILER_IS_CLANG ON)
set(CMAKE_COMPILER_IS_GNUCXX OFF)
endif()
@ -140,8 +133,7 @@ if(CMAKE_CXX_COMPILER_LOADED)
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_COMPILER_IS_ELBRUSCXX ON)
set(CMAKE_CXX_COMPILER_ID "Elbrus")
message(
STATUS "Detected Elbrus C++ compiler ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "Detected Elbrus C++ compiler ${CMAKE_CXX_COMPILER_VERSION}")
else()
set(CMAKE_COMPILER_IS_ELBRUSCXX OFF)
endif()
@ -152,20 +144,17 @@ if(CMAKE_CXX_COMPILER_LOADED)
unset(tmp_lxx_probe_result)
endif()
# Hard coding the compiler version is ugly from cmake POV, but at least gives
# user a friendly error message. The most critical demand for C++ compiler is
# support of C++11 lambdas, added only in version 4.5
# Hard coding the compiler version is ugly from cmake POV, but at least gives user a friendly error message. The most
# critical demand for C++ compiler is support of C++11 lambdas, added only in version 4.5
# https://gcc.gnu.org/projects/cxx0x.html
if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND NOT
CMAKE_COMPILER_IS_ELBRUSC)
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND NOT CMAKE_COMPILER_IS_ELBRUSC)
message(FATAL_ERROR "
Your GCC version is ${CMAKE_C_COMPILER_VERSION}, please update")
endif()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.5
AND NOT CMAKE_COMPILER_IS_ELBRUSCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.5 AND NOT CMAKE_COMPILER_IS_ELBRUSCXX)
message(FATAL_ERROR "
Your G++ version is ${CMAKE_CXX_COMPILER_VERSION}, please update")
endif()
@ -210,12 +199,10 @@ endif()
if(NOT CMAKE_SYSTEM_ARCH)
if(CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_ARCHITECTURE_ID)
string(TOLOWER "${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_ARCHITECTURE_ID}"
CMAKE_SYSTEM_ARCH)
string(TOLOWER "${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_ARCHITECTURE_ID}" CMAKE_SYSTEM_ARCH)
if(CMAKE_SYSTEM_ARCH STREQUAL "x86")
set(X86_32 TRUE)
elseif(CMAKE_SYSTEM_ARCH STREQUAL "x86_64" OR CMAKE_SYSTEM_ARCH STREQUAL
"x64")
elseif(CMAKE_SYSTEM_ARCH STREQUAL "x86_64" OR CMAKE_SYSTEM_ARCH STREQUAL "x64")
set(X86_64 TRUE)
set(CMAKE_SYSTEM_ARCH "x86_64")
elseif(CMAKE_SYSTEM_ARCH MATCHES "^(aarch.*|arm.*)")
@ -263,8 +250,7 @@ if(NOT CMAKE_SYSTEM_ARCH)
set(X86_32 TRUE)
set(CMAKE_SYSTEM_ARCH "x86")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES
"amd64.*|[xXiI]86_64.*|AMD64.*|[iI][3-6]86.*|[xXiI]86.*")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|[xXiI]86_64.*|AMD64.*|[iI][3-6]86.*|[xXiI]86.*")
if(CMAKE_TARGET_BITNESS EQUAL 64)
set(X86_64 TRUE)
set(CMAKE_SYSTEM_ARCH "x86_64")
@ -347,18 +333,15 @@ if(NOT DEFINED CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
)
))
set(CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET TRUE)
message(STATUS "Assume СAN RUN A BUILT EXECUTABLES,"
" since host (${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_ARCH})"
message(STATUS "Assume СAN RUN A BUILT EXECUTABLES," " since host (${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_ARCH})"
" match target (${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_ARCH})")
else()
if(CMAKE_C_COMPILER_LOADED)
include(CheckCSourceRuns)
check_c_source_runs("int main(void) { return 0; }"
CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
check_c_source_runs("int main(void) { return 0; }" CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
elseif(CMAKE_CXX_COMPILER_LOADED)
include(CheckCXXSourceRuns)
check_cxx_source_runs("int main(void) { return 0; }"
CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
check_cxx_source_runs("int main(void) { return 0; }" CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
endif()
if(NOT CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
message(STATUS "Force CMAKE_CROSSCOMPILING to TRUE")
@ -373,15 +356,13 @@ if(MSVC)
check_compiler_flag("/fsanitize=undefined" CC_HAS_UBSAN)
else()
#
# GCC started to warn for unused result starting from 4.2, and this is when it
# introduced -Wno-unused-result GCC can also be built on top of llvm runtime
# (on mac).
# GCC started to warn for unused result starting from 4.2, and this is when it introduced -Wno-unused-result GCC can
# also be built on top of llvm runtime (on mac).
check_compiler_flag("-Wno-unknown-pragmas" CC_HAS_WNO_UNKNOWN_PRAGMAS)
check_compiler_flag("-Wextra" CC_HAS_WEXTRA)
check_compiler_flag("-Werror" CC_HAS_WERROR)
check_compiler_flag("-fexceptions" CC_HAS_FEXCEPTIONS)
check_compiler_flag("-fno-semantic-interposition"
CC_HAS_FNO_SEMANTIC_INTERPOSITION)
check_compiler_flag("-fno-semantic-interposition" CC_HAS_FNO_SEMANTIC_INTERPOSITION)
if(CMAKE_CXX_COMPILER_LOADED)
check_cxx_compiler_flag("-fcxx-exceptions" CC_HAS_FCXX_EXCEPTIONS)
endif()
@ -463,34 +444,26 @@ if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG}
OUTPUT_VARIABLE gcc_info_v
ERROR_VARIABLE gcc_info_v)
string(REGEX MATCH "^(.+\nCOLLECT_GCC=)([^ \n]+)(\n.+)$" gcc_collect_valid
${gcc_info_v})
string(REGEX MATCH "^(.+\nCOLLECT_GCC=)([^ \n]+)(\n.+)$" gcc_collect_valid ${gcc_info_v})
if(gcc_collect_valid)
string(REGEX REPLACE "^(.+\nCOLLECT_GCC=)([^ \n]+)(\n.+)$" "\\2"
gcc_collect ${gcc_info_v})
string(REGEX REPLACE "^(.+\nCOLLECT_GCC=)([^ \n]+)(\n.+)$" "\\2" gcc_collect ${gcc_info_v})
endif()
string(REGEX MATCH
"^(.+\nCOLLECT_LTO_WRAPPER=)([^ \n]+/lto-wrapper)(\n.+)$"
gcc_lto_wrapper_valid ${gcc_info_v})
string(REGEX MATCH "^(.+\nCOLLECT_LTO_WRAPPER=)([^ \n]+/lto-wrapper)(\n.+)$" gcc_lto_wrapper_valid ${gcc_info_v})
if(gcc_lto_wrapper_valid)
string(REGEX
REPLACE "^(.+\nCOLLECT_LTO_WRAPPER=)([^ \n]+/lto-wrapper)(\n.+)$"
"\\2" gcc_lto_wrapper ${gcc_info_v})
string(REGEX REPLACE "^(.+\nCOLLECT_LTO_WRAPPER=)([^ \n]+/lto-wrapper)(\n.+)$" "\\2" gcc_lto_wrapper
${gcc_info_v})
endif()
set(gcc_suffix "")
if(gcc_collect_valid AND gcc_collect)
string(REGEX MATCH "^(.*(cc|\\+\\+))(-.+)$" gcc_suffix_valid
${gcc_collect})
string(REGEX MATCH "^(.*(cc|\\+\\+))(-.+)$" gcc_suffix_valid ${gcc_collect})
if(gcc_suffix_valid)
string(REGEX REPLACE "^(.*(cc|\\+\\+))(-.+)$" "\\3" gcc_suffix
${gcc_collect})
string(REGEX REPLACE "^(.*(cc|\\+\\+))(-.+)$" "\\3" gcc_suffix ${gcc_collect})
endif()
endif()
get_filename_component(gcc_dir ${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER}
DIRECTORY)
get_filename_component(gcc_dir ${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER} DIRECTORY)
if(NOT CMAKE_GCC_AR)
find_program(
CMAKE_GCC_AR
@ -526,10 +499,7 @@ if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG}
AND CMAKE_GCC_NM
AND CMAKE_GCC_RANLIB
AND gcc_lto_wrapper)
message(
STATUS
"Found GCC's LTO toolset: ${gcc_lto_wrapper}, ${CMAKE_GCC_AR}, ${CMAKE_GCC_RANLIB}"
)
message(STATUS "Found GCC's LTO toolset: ${gcc_lto_wrapper}, ${CMAKE_GCC_AR}, ${CMAKE_GCC_RANLIB}")
set(GCC_LTO_CFLAGS "-flto -fno-fat-lto-objects -fuse-linker-plugin")
set(GCC_LTO_AVAILABLE TRUE)
message(STATUS "Link-Time Optimization by GCC is available")
@ -565,11 +535,9 @@ if(CMAKE_COMPILER_IS_CLANG)
unset(clang_libdirs)
unset(clang_libdirs_x)
if(clang_probe_result EQUAL 0)
string(REGEX MATCH "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)"
regexp_valid ${clang_search_dirs})
string(REGEX MATCH "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs})
if(regexp_valid)
string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3"
list ${clang_search_dirs})
string(REGEX REPLACE "(^|\n.*)(.*programs: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs})
string(REPLACE ":" ";" list "${list}")
foreach(dir IN LISTS list)
get_filename_component(dir "${dir}" REALPATH)
@ -582,11 +550,9 @@ if(CMAKE_COMPILER_IS_CLANG)
list(APPEND clang_bindirs "${clang_bindirs_x}")
list(REMOVE_DUPLICATES clang_bindirs)
endif()
string(REGEX MATCH "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)"
regexp_valid ${clang_search_dirs})
string(REGEX MATCH "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" regexp_valid ${clang_search_dirs})
if(regexp_valid)
string(REGEX REPLACE "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" "\\3"
list ${clang_search_dirs})
string(REGEX REPLACE "(^|\n.*)(.*libraries: =)([^\n]+)((\n.*)|$)" "\\3" list ${clang_search_dirs})
string(REPLACE ":" ";" list "${list}")
foreach(dir IN LISTS list)
get_filename_component(dir "${dir}" REALPATH)
@ -600,21 +566,16 @@ if(CMAKE_COMPILER_IS_CLANG)
list(REMOVE_DUPLICATES clang_libdirs)
endif()
else()
get_filename_component(clang_bindirs
${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER} DIRECTORY)
get_filename_component(clang_bindirs ${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER} DIRECTORY)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(clang_libdirs ${clang_bindirs})
else()
get_filename_component(
clang_libdirs "${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER}/../lib"
REALPATH)
get_filename_component(clang_libdirs "${CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER}/../lib" REALPATH)
endif()
endif()
if(clang_bindirs AND clang_libdirs)
message(
STATUS
"Found CLANG/LLVM directories: ${clang_bindirs}, ${clang_libdirs}")
message(STATUS "Found CLANG/LLVM directories: ${clang_bindirs}, ${clang_libdirs}")
else()
message(STATUS "Could NOT find CLANG/LLVM directories (bin and/or lib).")
endif()
@ -622,8 +583,7 @@ if(CMAKE_COMPILER_IS_CLANG)
if(NOT CMAKE_CLANG_LD AND clang_bindirs)
find_program(
CMAKE_CLANG_LD
NAMES lld-link ld.lld "ld${CMAKE_TARGET_BITNESS}.lld" lld llvm-link
llvm-ld
NAMES lld-link ld.lld "ld${CMAKE_TARGET_BITNESS}.lld" lld llvm-link llvm-ld
PATHS ${clang_bindirs}
NO_DEFAULT_PATH)
endif()
@ -666,31 +626,21 @@ if(CMAKE_COMPILER_IS_CLANG)
if(CLANG_LTO_PLUGIN)
message(STATUS "Found CLANG/LLVM's plugin for LTO: ${CLANG_LTO_PLUGIN}")
else()
message(
STATUS
"Could NOT find CLANG/LLVM's plugin (${clang_lto_plugin_name}) for LTO."
)
message(STATUS "Could NOT find CLANG/LLVM's plugin (${clang_lto_plugin_name}) for LTO.")
endif()
if(CMAKE_CLANG_LD)
message(STATUS "Found CLANG/LLVM's linker for LTO: ${CMAKE_CLANG_LD}")
else()
message(
STATUS
"Could NOT find CLANG/LLVM's linker (lld, llvm-ld, llvm-link) for LTO."
)
message(STATUS "Could NOT find CLANG/LLVM's linker (lld, llvm-ld, llvm-link) for LTO.")
endif()
if(CMAKE_CLANG_AR
AND CMAKE_CLANG_RANLIB
AND CMAKE_CLANG_NM)
message(
STATUS
"Found CLANG/LLVM's binutils for LTO: ${CMAKE_CLANG_AR}, ${CMAKE_CLANG_RANLIB}, ${CMAKE_CLANG_NM}"
)
message(STATUS "Found CLANG/LLVM's binutils for LTO: ${CMAKE_CLANG_AR}, ${CMAKE_CLANG_RANLIB}, ${CMAKE_CLANG_NM}")
else()
message(
STATUS "Could NOT find CLANG/LLVM's binutils (ar, ranlib, nm) for LTO.")
message(STATUS "Could NOT find CLANG/LLVM's binutils (ar, ranlib, nm) for LTO.")
endif()
unset(clang_lto_plugin_name)
@ -704,22 +654,17 @@ if(CMAKE_COMPILER_IS_CLANG)
AND CMAKE_CLANG_NM
AND CMAKE_CLANG_RANLIB
AND ((CLANG_LTO_PLUGIN AND CMAKE_LD_GOLD)
OR (CMAKE_CLANG_LD AND NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux"
AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
OR APPLE
))
OR (CMAKE_CLANG_LD AND NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
OR APPLE))
if(ANDROID AND CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 12)
set(CLANG_LTO_AVAILABLE FALSE)
message(
STATUS
"Link-Time Optimization by CLANG/LLVM is available but unusable due https://reviews.llvm.org/D79919"
)
STATUS "Link-Time Optimization by CLANG/LLVM is available but unusable due https://reviews.llvm.org/D79919")
else()
set(CLANG_LTO_AVAILABLE TRUE)
message(STATUS "Link-Time Optimization by CLANG/LLVM is available")
endif()
elseif(CMAKE_TOOLCHAIN_FILE
AND NOT CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 7.0)
elseif(CMAKE_TOOLCHAIN_FILE AND NOT CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 7.0)
set(CLANG_LTO_AVAILABLE TRUE)
if(NOT CMAKE_CLANG_LD)
set(CMAKE_CLANG_LD ${CMAKE_LINKER})
@ -733,10 +678,7 @@ if(CMAKE_COMPILER_IS_CLANG)
if(NOT CMAKE_CLANG_RANLIB)
set(CMAKE_CLANG_RANLIB ${CMAKE_RANLIB})
endif()
message(
STATUS
"Assume Link-Time Optimization by CLANG/LLVM is available via ${CMAKE_TOOLCHAIN_FILE}"
)
message(STATUS "Assume Link-Time Optimization by CLANG/LLVM is available via ${CMAKE_TOOLCHAIN_FILE}")
else()
set(CLANG_LTO_AVAILABLE FALSE)
message(STATUS "Link-Time Optimization by CLANG/LLVM is NOT available")
@ -772,8 +714,7 @@ if(ENABLE_BACKTRACE)
if(IBERTY_LIBRARY)
check_library_exists(${IBERTY_LIBRARY} cplus_demangle "" HAVE_IBERTY_LIB)
endif()
set(CMAKE_REQUIRED_DEFINITIONS -DPACKAGE=${PACKAGE}
-DPACKAGE_VERSION=${PACKAGE_VERSION})
set(CMAKE_REQUIRED_DEFINITIONS -DPACKAGE=${PACKAGE} -DPACKAGE_VERSION=${PACKAGE_VERSION})
check_include_files(bfd.h HAVE_BFD_H)
set(CMAKE_REQUIRED_DEFINITIONS)
find_package(ZLIB)
@ -783,8 +724,7 @@ if(ENABLE_BACKTRACE)
AND ZLIB_FOUND)
set(HAVE_BFD ON)
set(BFD_LIBRARIES ${BFD_LIBRARY} ${IBERTY_LIBRARY} ${ZLIB_LIBRARIES})
find_package_message(BFD_LIBRARIES "Found libbfd and dependencies"
${BFD_LIBRARIES})
find_package_message(BFD_LIBRARIES "Found libbfd and dependencies" ${BFD_LIBRARIES})
if(TARGET_OS_FREEBSD AND NOT TARGET_OS_DEBIAN_FREEBSD)
set(BFD_LIBRARIES ${BFD_LIBRARIES} iconv)
endif()
@ -859,12 +799,9 @@ macro(setup_compile_flags)
add_compile_flags("C;CXX" "-fno-semantic-interposition")
endif()
if(MSVC)
# checks for /EHa or /clr options exists, i.e. is enabled structured async
# WinNT exceptions
string(REGEX MATCH "^(.* )*[-/]EHc*a( .*)*$" msvc_async_eh_enabled
"${CXX_FLAGS}" "${C_FLAGS}")
string(REGEX MATCH "^(.* )*[-/]clr( .*)*$" msvc_clr_enabled "${CXX_FLAGS}"
"${C_FLAGS}")
# checks for /EHa or /clr options exists, i.e. is enabled structured async WinNT exceptions
string(REGEX MATCH "^(.* )*[-/]EHc*a( .*)*$" msvc_async_eh_enabled "${CXX_FLAGS}" "${C_FLAGS}")
string(REGEX MATCH "^(.* )*[-/]clr( .*)*$" msvc_clr_enabled "${CXX_FLAGS}" "${C_FLAGS}")
# remote any /EH? options
string(REGEX REPLACE "( *[-/]-*EH[csa]+ *)+" "" CXX_FLAGS "${CXX_FLAGS}")
string(REGEX REPLACE "( *[-/]-*EH[csa]+ *)+" "" C_FLAGS "${C_FLAGS}")
@ -887,21 +824,17 @@ macro(setup_compile_flags)
endif()
endif()
# In C a global variable without a storage specifier (static/extern) and
# without an initialiser is called a tentative definition. The language
# permits multiple tentative definitions in the single translation unit; i.e.
# int foo; int foo; is perfectly ok. GNU toolchain goes even further, allowing
# multiple tentative definitions in *different* translation units. Internally,
# variables introduced via tentative definitions are implemented as common
# symbols. Linker permits multiple definitions if they are common symbols, and
# it picks one arbitrarily for inclusion in the binary being linked.
# In C a global variable without a storage specifier (static/extern) and without an initialiser is called a tentative
# definition. The language permits multiple tentative definitions in the single translation unit; i.e. int foo; int
# foo; is perfectly ok. GNU toolchain goes even further, allowing multiple tentative definitions in *different*
# translation units. Internally, variables introduced via tentative definitions are implemented as common symbols.
# Linker permits multiple definitions if they are common symbols, and it picks one arbitrarily for inclusion in the
# binary being linked.
#
# -fno-common forces GNU toolchain to behave in a more standard-conformant way
# in respect to tentative definitions and it prevents common symbols
# generation. Since we are a cross-platform project it really makes sense.
# There are toolchains that dont implement GNU style handling of the
# tentative definitions and there are platforms lacking proper support for
# common symbols (osx).
# -fno-common forces GNU toolchain to behave in a more standard-conformant way in respect to tentative definitions and
# it prevents common symbols generation. Since we are a cross-platform project it really makes sense. There are
# toolchains that dont implement GNU style handling of the tentative definitions and there are platforms lacking
# proper support for common symbols (osx).
if(CC_HAS_FNO_COMMON)
add_compile_flags("C;CXX" "-fno-common")
endif()
@ -920,9 +853,8 @@ macro(setup_compile_flags)
add_compile_flags("C;CXX" "/Gy")
endif()
# We must set -fno-omit-frame-pointer here, since we rely on frame pointer
# when getting a backtrace, and it must be used consistently across all object
# files. The same reasoning applies to -fno-stack-protector switch.
# We must set -fno-omit-frame-pointer here, since we rely on frame pointer when getting a backtrace, and it must be
# used consistently across all object files. The same reasoning applies to -fno-stack-protector switch.
if(ENABLE_BACKTRACE)
if(CC_HAS_FNO_OMIT_FRAME_POINTER)
add_compile_flags("C;CXX" "-fno-omit-frame-pointer")
@ -933,8 +865,7 @@ macro(setup_compile_flags)
if(MSVC_VERSION LESS 1900)
message(
FATAL_ERROR
"At least \"Microsoft C/C++ Compiler\" version 19.0.24234.1 (Visual Studio 2015 Update 3) is required."
)
"At least \"Microsoft C/C++ Compiler\" version 19.0.24234.1 (Visual Studio 2015 Update 3) is required.")
endif()
if(NOT MSVC_VERSION LESS 1910)
add_compile_flags("CXX" "/Zc:__cplusplus")
@ -955,8 +886,7 @@ macro(setup_compile_flags)
add_definitions("-D__STDC_CONSTANT_MACROS=1")
add_definitions("-D_HAS_EXCEPTIONS=1")
# Only add -Werror if it's a debug build, done by developers. Release builds
# should not cause extra trouble.
# Only add -Werror if it's a debug build, done by developers. Release builds should not cause extra trouble.
if(CC_HAS_WERROR
AND (CI
OR CMAKE_CONFIGURATION_TYPES
@ -976,17 +906,15 @@ macro(setup_compile_flags)
endif()
endif()
if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG}
AND CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 5)
if(CMAKE_COMPILER_IS_GNU${CMAKE_PRIMARY_LANG} AND CMAKE_${CMAKE_PRIMARY_LANG}_COMPILER_VERSION VERSION_LESS 5)
# G++ bug. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31488
add_compile_flags("CXX" "-Wno-invalid-offsetof")
endif()
if(MINGW)
# Disable junk MINGW's warnings that issued due to incompatibilities and
# shortcomings of MINGW, since the code is checked by builds with GCC, CLANG
# and MSVC.
add_compile_flags("C;CXX" "-Wno-format-extra-args" "-Wno-format"
"-Wno-cast-function-type" "-Wno-implicit-fallthrough")
# Disable junk MINGW's warnings that issued due to incompatibilities and shortcomings of MINGW, since the code is
# checked by builds with GCC, CLANG and MSVC.
add_compile_flags("C;CXX" "-Wno-format-extra-args" "-Wno-format" "-Wno-cast-function-type"
"-Wno-implicit-fallthrough")
endif()
if(ENABLE_ASAN)
@ -1000,8 +928,7 @@ macro(setup_compile_flags)
if(ENABLE_UBSAN)
if(NOT MSVC)
add_compile_flags("C;CXX" "-fsanitize=undefined"
"-fsanitize-undefined-trap-on-error")
add_compile_flags("C;CXX" "-fsanitize=undefined" "-fsanitize-undefined-trap-on-error")
else()
add_compile_flags("C;CXX" "/fsanitize=undefined")
endif()
@ -1010,17 +937,13 @@ macro(setup_compile_flags)
if(ENABLE_GCOV)
if(NOT HAVE_GCOV)
message(
FATAL_ERROR "ENABLE_GCOV option requested but gcov library is not found"
)
message(FATAL_ERROR "ENABLE_GCOV option requested but gcov library is not found")
endif()
add_compile_flags("C;CXX" "-fprofile-arcs" "-ftest-coverage")
set(EXE_LINKER_FLAGS "${EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
set(SHARED_LINKER_FLAGS
"${SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
set(MODULE_LINKER_FLAGS
"${MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
set(SHARED_LINKER_FLAGS "${SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
set(MODULE_LINKER_FLAGS "${MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
# add_library(gcov SHARED IMPORTED)
endif()
@ -1030,16 +953,12 @@ macro(setup_compile_flags)
if(CMAKE_COMPILER_IS_GNUCC AND LTO_ENABLED)
add_compile_flags("C;CXX" ${GCC_LTO_CFLAGS})
set(EXE_LINKER_FLAGS
"${EXE_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm -fwhole-program")
set(SHARED_LINKER_FLAGS
"${SHARED_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm")
set(MODULE_LINKER_FLAGS
"${MODULE_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm")
set(EXE_LINKER_FLAGS "${EXE_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm -fwhole-program")
set(SHARED_LINKER_FLAGS "${SHARED_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm")
set(MODULE_LINKER_FLAGS "${MODULE_LINKER_FLAGS} ${GCC_LTO_CFLAGS} -fverbose-asm")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
# Pass the same optimization flags to the linker
set(compile_flags
"${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set(compile_flags "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set(EXE_LINKER_FLAGS "${EXE_LINKER_FLAGS} ${compile_flags}")
set(SHARED_LINKER_FLAGS "${SHARED_LINKER_FLAGS} ${compile_flags}")
set(MODULE_LINKER_FLAGS "${MODULE_LINKER_FLAGS} ${compile_flags}")
@ -1055,9 +974,8 @@ macro(setup_compile_flags)
add_compile_flags("C;CXX" "/GL")
foreach(linkmode IN ITEMS EXE SHARED STATIC MODULE)
set(${linkmode}_LINKER_FLAGS "${${linkmode}_LINKER_FLAGS} /LTCG")
string(REGEX
REPLACE "^(.*)(/INCREMENTAL)(:YES)?(:NO)?( ?.*)$" "\\1\\2:NO\\5"
${linkmode}_LINKER_FLAGS "${${linkmode}_LINKER_FLAGS}")
string(REGEX REPLACE "^(.*)(/INCREMENTAL)(:YES)?(:NO)?( ?.*)$" "\\1\\2:NO\\5" ${linkmode}_LINKER_FLAGS
"${${linkmode}_LINKER_FLAGS}")
string(STRIP "${${linkmode}_LINKER_FLAGS}" ${linkmode}_LINKER_FLAGS)
foreach(
config IN
@ -1065,14 +983,10 @@ macro(setup_compile_flags)
ITEMS Release MinSizeRel RelWithDebInfo Debug)
string(TOUPPER "${config}" config_uppercase)
if(DEFINED "CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}")
string(
REGEX
REPLACE "^(.*)(/INCREMENTAL)(:YES)?(:NO)?( ?.*)$" "\\1\\2:NO\\5"
altered_flags
"${CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}}")
string(REGEX REPLACE "^(.*)(/INCREMENTAL)(:YES)?(:NO)?( ?.*)$" "\\1\\2:NO\\5" altered_flags
"${CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}}")
string(STRIP "${altered_flags}" altered_flags)
if(NOT "${altered_flags}" STREQUAL
"${CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}}")
if(NOT "${altered_flags}" STREQUAL "${CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}}")
set(CMAKE_${linkmode}_LINKER_FLAGS_${config_uppercase}
"${altered_flags}"
CACHE STRING "Altered: '/INCREMENTAL' removed for LTO" FORCE)
@ -1089,10 +1003,8 @@ macro(setup_compile_flags)
foreach(lang IN ITEMS C CXX)
string(TOUPPER "${config}" config_uppercase)
if(DEFINED "CMAKE_${lang}_FLAGS_${config_uppercase}")
string(REPLACE "/O2" "/Ox" altered_flags
"${CMAKE_${lang}_FLAGS_${config_uppercase}}")
if(NOT "${altered_flags}" STREQUAL
"${CMAKE_${lang}_FLAGS_${config_uppercase}}")
string(REPLACE "/O2" "/Ox" altered_flags "${CMAKE_${lang}_FLAGS_${config_uppercase}}")
if(NOT "${altered_flags}" STREQUAL "${CMAKE_${lang}_FLAGS_${config_uppercase}}")
set(CMAKE_${lang}_FLAGS_${config_uppercase}
"${altered_flags}"
CACHE STRING "Altered: '/O2' replaced by '/Ox' for LTO" FORCE)
@ -1120,12 +1032,9 @@ macro(setup_compile_flags)
endif()
add_compile_flags("C;CXX" ${CLANG_LTO_FLAG})
if(NOT MSVC)
set(EXE_LINKER_FLAGS
"${EXE_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm -fwhole-program")
set(SHARED_LINKER_FLAGS
"${SHARED_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm")
set(MODULE_LINKER_FLAGS
"${MODULE_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm")
set(EXE_LINKER_FLAGS "${EXE_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm -fwhole-program")
set(SHARED_LINKER_FLAGS "${SHARED_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm")
set(MODULE_LINKER_FLAGS "${MODULE_LINKER_FLAGS} ${CLANG_LTO_FLAG} -fverbose-asm")
endif()
endif()
@ -1133,15 +1042,13 @@ macro(setup_compile_flags)
if(CMAKE_CXX_COMPILER_LOADED)
set(CMAKE_CXX_FLAGS
${CXX_FLAGS}
CACHE STRING "Flags used by the C++ compiler during all build types"
FORCE)
CACHE STRING "Flags used by the C++ compiler during all build types" FORCE)
unset(CXX_FLAGS)
endif()
if(CMAKE_C_COMPILER_LOADED)
set(CMAKE_C_FLAGS
${C_FLAGS}
CACHE STRING "Flags used by the C compiler during all build types"
FORCE)
CACHE STRING "Flags used by the C compiler during all build types" FORCE)
unset(C_FLAGS)
endif()
set(CMAKE_EXE_LINKER_FLAGS
@ -1149,17 +1056,13 @@ macro(setup_compile_flags)
CACHE STRING "Flags used by the linker" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS
${SHARED_LINKER_FLAGS}
CACHE STRING "Flags used by the linker during the creation of dll's"
FORCE)
CACHE STRING "Flags used by the linker during the creation of dll's" FORCE)
set(CMAKE_STATIC_LINKER_FLAGS
${STATIC_LINKER_FLAGS}
CACHE STRING
"Flags used by the linker during the creation of static libraries"
FORCE)
CACHE STRING "Flags used by the linker during the creation of static libraries" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS
${MODULE_LINKER_FLAGS}
CACHE STRING "Flags used by the linker during the creation of modules"
FORCE)
CACHE STRING "Flags used by the linker during the creation of modules" FORCE)
unset(EXE_LINKER_FLAGS)
unset(SHARED_LINKER_FLAGS)
unset(STATIC_LINKER_FLAGS)
@ -1183,9 +1086,7 @@ macro(probe_libcxx_filesystem)
if(NOT DEFINED CMAKE_CXX_STANDARD)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_17 HAS_CXX17)
if(NOT HAS_CXX17 LESS 0
AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 5))
if(NOT HAS_CXX17 LESS 0 AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5))
set(CMAKE_CXX_STANDARD 17)
elseif(NOT HAS_CXX14 LESS 0)
set(CMAKE_CXX_STANDARD 14)
@ -1198,14 +1099,11 @@ macro(probe_libcxx_filesystem)
endif()
set(stdfs_probe_clear_cxx_standard ON)
endif()
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS 1.25.23)
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.25.23)
if(CMAKE_VERSION VERSION_LESS 3.14)
set(stdfs_probe_flags ${stdfs_probe_flags}
"-Wl,--allow-multiple-definition")
set(stdfs_probe_flags ${stdfs_probe_flags} "-Wl,--allow-multiple-definition")
else()
set(CMAKE_REQUIRED_LINK_OPTIONS ${stdfs_probe_save_link_options}
"-Wl,--allow-multiple-definition")
set(CMAKE_REQUIRED_LINK_OPTIONS ${stdfs_probe_save_link_options} "-Wl,--allow-multiple-definition")
endif()
endif()
set(CMAKE_REQUIRED_FLAGS ${stdfs_probe_flags})
@ -1261,40 +1159,25 @@ macro(probe_libcxx_filesystem)
check_cxx_source_compiles("${stdfs_probe_code}" LIBCXX_FILESYSTEM_none)
if(LIBCXX_FILESYSTEM_none)
message(
STATUS "No linking with additional library needed for std::filesystem"
)
message(STATUS "No linking with additional library needed for std::filesystem")
else()
set(CMAKE_REQUIRED_LIBRARIES ${stdfs_probe_save_libraries} "stdc++fs")
check_cxx_source_compiles("${stdfs_probe_code}"
LIBCXX_FILESYSTEM_stdcxxfs)
check_cxx_source_compiles("${stdfs_probe_code}" LIBCXX_FILESYSTEM_stdcxxfs)
if(LIBCXX_FILESYSTEM_stdcxxfs)
set(LIBCXX_FILESYSTEM "stdc++fs")
message(
STATUS
"Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem"
)
message(STATUS "Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem")
else()
set(CMAKE_REQUIRED_LIBRARIES ${stdfs_probe_save_libraries} "c++fs")
check_cxx_source_compiles("${stdfs_probe_code}"
LIBCXX_FILESYSTEM_cxxfs)
check_cxx_source_compiles("${stdfs_probe_code}" LIBCXX_FILESYSTEM_cxxfs)
if(LIBCXX_FILESYSTEM_cxxfs)
set(LIBCXX_FILESYSTEM "c++fs")
message(
STATUS
"Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem"
)
message(STATUS "Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem")
else()
set(CMAKE_REQUIRED_LIBRARIES ${stdfs_probe_save_libraries}
"c++experimental")
check_cxx_source_compiles("${stdfs_probe_code}"
LIBCXX_FILESYSTEM_cxxexperimental)
set(CMAKE_REQUIRED_LIBRARIES ${stdfs_probe_save_libraries} "c++experimental")
check_cxx_source_compiles("${stdfs_probe_code}" LIBCXX_FILESYSTEM_cxxexperimental)
if(LIBCXX_FILESYSTEM_cxxexperimental)
set(LIBCXX_FILESYSTEM "c++experimental")
message(
STATUS
"Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem"
)
message(STATUS "Linking with ${LIBCXX_FILESYSTEM} is required for std::filesystem")
else()
message(STATUS "No support for std::filesystem")
endif()

View File

@ -1,4 +1,4 @@
# Copyright (c) 2012-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
# Copyright (c) 2012-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> ###############################################
# SPDX-License-Identifier: Apache-2.0
if(CMAKE_VERSION VERSION_LESS 3.8.2)
@ -22,8 +22,7 @@ if(NOT DEFINED ENABLE_MEMCHECK)
set(MEMCHECK_OPTION_NAME "ENABLE_MEMCHECK")
endif()
if(MEMCHECK_OPTION_NAME STREQUAL "ENABLE_MEMCHECK")
option(ENABLE_MEMCHECK
"Enable integration with valgrind, a memory analyzing tool" OFF)
option(ENABLE_MEMCHECK "Enable integration with valgrind, a memory analyzing tool" OFF)
elseif(${MEMCHECK_OPTION_NAME})
set(ENABLE_MEMCHECK ON)
else()
@ -36,18 +35,12 @@ check_library_exists(gcov __gcov_flush "" HAVE_GCOV)
option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" OFF)
option(ENABLE_GPROF
"Enable integration with gprof, a performance analyzing tool" OFF)
option(ENABLE_GPROF "Enable integration with gprof, a performance analyzing tool" OFF)
option(
ENABLE_ASAN
"Enable AddressSanitizer, a fast memory error detector based on compiler instrumentation"
OFF)
option(ENABLE_ASAN "Enable AddressSanitizer, a fast memory error detector based on compiler instrumentation" OFF)
option(
ENABLE_UBSAN
"Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector based on compiler instrumentation"
OFF)
option(ENABLE_UBSAN
"Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector based on compiler instrumentation" OFF)
if(ENABLE_MEMCHECK)
if(CMAKE_CXX_COMPILER_LOADED)
@ -58,10 +51,7 @@ if(ENABLE_MEMCHECK)
check_include_file(valgrind/memcheck.h HAVE_VALGRIND_MEMCHECK_H)
endif()
if(NOT HAVE_VALGRIND_MEMCHECK_H)
message(
FATAL_ERROR
"${MEMCHECK_OPTION_NAME} option is set but valgrind/memcheck.h is not found"
)
message(FATAL_ERROR "${MEMCHECK_OPTION_NAME} option is set but valgrind/memcheck.h is not found")
endif()
endif()

View File

@ -1,4 +1,4 @@
# Copyright (c) 2012-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
# Copyright (c) 2012-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> ###############################################
# SPDX-License-Identifier: Apache-2.0
if(CMAKE_VERSION VERSION_LESS 3.8.2)
@ -27,10 +27,8 @@ macro(add_compile_flags languages)
endmacro(add_compile_flags)
macro(remove_flag varname flag)
string(REGEX REPLACE "^(.*)( ${flag} )(.*)$" "\\1 \\3" ${varname}
${${varname}})
string(REGEX REPLACE "^((.+ )*)(${flag})(( .+)*)$" "\\1\\4" ${varname}
${${varname}})
string(REGEX REPLACE "^(.*)( ${flag} )(.*)$" "\\1 \\3" ${varname} ${${varname}})
string(REGEX REPLACE "^((.+ )*)(${flag})(( .+)*)$" "\\1\\4" ${varname} ${${varname}})
endmacro(remove_flag)
macro(remove_compile_flag languages flag)
@ -51,9 +49,8 @@ macro(set_source_files_compile_flags)
set(_lang "")
if("${_file_ext}" STREQUAL ".m")
set(_lang OBJC)
# CMake believes that Objective C is a flavor of C++, not C, and uses g++
# compiler for .m files. LANGUAGE property forces CMake to use CC for
# ${file}
# CMake believes that Objective C is a flavor of C++, not C, and uses g++ compiler for .m files. LANGUAGE property
# forces CMake to use CC for ${file}
set_source_files_properties(${file} PROPERTIES LANGUAGE C)
elseif("${_file_ext}" STREQUAL ".mm")
set(_lang OBJCXX)
@ -87,10 +84,8 @@ macro(semver_parse str)
set(_semver_prerelease "")
set(_semver_buildmetadata_withplus "")
set(_semver_buildmetadata "")
if("${str}"
MATCHES
"^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?([-+]-*[0-9a-zA-Z]+.*)?$"
)
if("${str}" MATCHES
"^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?([-+]-*[0-9a-zA-Z]+.*)?$")
set(_semver_major ${CMAKE_MATCH_1})
set(_semver_minor ${CMAKE_MATCH_2})
set(_semver_patch ${CMAKE_MATCH_3})
@ -102,13 +97,11 @@ macro(semver_parse str)
elseif("${_semver_extra}" MATCHES "^([.-][a-zA-Z0-9-]+)*(\\+[^+]+)?$")
set(_semver_prerelease_withdash "${CMAKE_MATCH_1}")
if(NOT "${_semver_prerelease_withdash}" STREQUAL "")
string(SUBSTRING "${_semver_prerelease_withdash}" 1 -1
_semver_prerelease)
string(SUBSTRING "${_semver_prerelease_withdash}" 1 -1 _semver_prerelease)
endif()
set(_semver_buildmetadata_withplus "${CMAKE_MATCH_2}")
if(NOT "${_semver_buildmetadata_withplus}" STREQUAL "")
string(SUBSTRING "${_semver_buildmetadata_withplus}" 1 -1
_semver_buildmetadata)
string(SUBSTRING "${_semver_buildmetadata_withplus}" 1 -1 _semver_buildmetadata)
endif()
set(_semver_ok TRUE)
else()
@ -117,19 +110,14 @@ macro(semver_parse str)
)
endif()
else()
set(_semver_err
"Версионная отметка в целом не соответствует шаблону `0.0.0[.0][-foo][+bar]` SemVer-спецификации"
)
set(_semver_err "Версионная отметка в целом не соответствует шаблону `0.0.0[.0][-foo][+bar]` SemVer-спецификации")
endif()
endmacro(semver_parse)
function(_semver_parse_probe str expect)
semver_parse(${str})
if(expect AND NOT _semver_ok)
message(
FATAL_ERROR
"semver_parse(${str}) expect SUCCESS, got ${_semver_ok}: ${_semver_err}"
)
message(FATAL_ERROR "semver_parse(${str}) expect SUCCESS, got ${_semver_ok}: ${_semver_err}")
elseif(NOT expect AND _semver_ok)
message(FATAL_ERROR "semver_parse(${str}) expect FAIL, got ${_semver_ok}")
endif()
@ -150,8 +138,7 @@ function(semver_parse_selfcheck)
_semver_parse_probe("1.0.0-alpha.1" TRUE)
_semver_parse_probe("1.0.0-alpha0.valid" TRUE)
_semver_parse_probe("1.0.0-alpha.0valid" TRUE)
_semver_parse_probe("1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay"
TRUE)
_semver_parse_probe("1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay" TRUE)
_semver_parse_probe("1.0.0-rc.1+build.1" TRUE)
_semver_parse_probe("2.0.0-rc.1+build.123" TRUE)
_semver_parse_probe("1.2.3-beta" TRUE)
@ -167,14 +154,12 @@ function(semver_parse_selfcheck)
_semver_parse_probe("1.2.3----R-S.12.9.1--.12+meta" TRUE)
_semver_parse_probe("1.2.3----RC-SNAPSHOT.12.9.1--.12" TRUE)
_semver_parse_probe("1.0.0+0.build.1-rc.10000aaa-kk-0.1" TRUE)
_semver_parse_probe(
"99999999999999999999999.999999999999999999.99999999999999999" TRUE)
_semver_parse_probe("99999999999999999999999.999999999999999999.99999999999999999" TRUE)
_semver_parse_probe("v1.0.0-0A.is.legal" TRUE)
_semver_parse_probe("1" FALSE)
_semver_parse_probe("1.2" FALSE)
# _semver_parse_probe("1.2.3-0123" FALSE)
# _semver_parse_probe("1.2.3-0123.0123" FALSE)
# _semver_parse_probe("1.2.3-0123" FALSE) _semver_parse_probe("1.2.3-0123.0123" FALSE)
_semver_parse_probe("1.1.2+.123" FALSE)
_semver_parse_probe("+invalid" FALSE)
_semver_parse_probe("-invalid" FALSE)
@ -238,10 +223,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_timestamp}" STREQUAL "%ci")
message(
FATAL_ERROR
"Please install latest version of git (`show --no-patch --format=%cI HEAD` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`show --no-patch --format=%cI HEAD` failed)")
endif()
endif()
@ -252,10 +234,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_tree}" STREQUAL "")
message(
FATAL_ERROR
"Please install latest version of git (`show --no-patch --format=%T HEAD` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`show --no-patch --format=%T HEAD` failed)")
endif()
execute_process(
@ -265,10 +244,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_commit}" STREQUAL "")
message(
FATAL_ERROR
"Please install latest version of git (`show --no-patch --format=%H HEAD` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`show --no-patch --format=%H HEAD` failed)")
endif()
execute_process(
@ -278,10 +254,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc)
message(
FATAL_ERROR
"Please install latest version of git (`status --untracked-files=no --porcelain` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`status --untracked-files=no --porcelain` failed)")
endif()
if(NOT "${_git_status}" STREQUAL "")
set(_git_commit "DIRTY-${_git_commit}")
@ -311,18 +284,12 @@ macro(git_get_versioninfo source_root_directory)
if(_rc)
message(
FATAL_ERROR
"Please install latest version of git (`git rev-list --count --no-merges --remove-empty HEAD` failed)"
)
"Please install latest version of git (`git rev-list --count --no-merges --remove-empty HEAD` failed)")
endif()
if(_git_whole_count GREATER 42 AND "${_git_tags_dump}" STREQUAL "")
message(
FATAL_ERROR
"Please fetch tags (`describe --tags --abbrev=0 --match=v[0-9]*` failed)"
)
message(FATAL_ERROR "Please fetch tags (`describe --tags --abbrev=0 --match=v[0-9]*` failed)")
else()
message(
NOTICE
"Falling back to version `0.0.0` (have you made an initial release?")
message(NOTICE "Falling back to version `0.0.0` (have you made an initial release?")
endif()
set(_git_last_vtag "0.0.0")
set(_git_trailing_commits ${_git_whole_count})
@ -340,10 +307,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_describe}" STREQUAL "")
message(
FATAL_ERROR
"Please install latest version of git (`describe --tags --all --long` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`describe --tags --all --long` failed)")
endif()
endif()
else()
@ -354,10 +318,7 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_describe}" STREQUAL "")
message(
FATAL_ERROR
"Please install latest version of git (`describe --tags --long --match=v[0-9]*`)"
)
message(FATAL_ERROR "Please install latest version of git (`describe --tags --long --match=v[0-9]*`)")
endif()
execute_process(
COMMAND ${GIT} rev-list --count "${_git_last_vtag}..HEAD"
@ -366,16 +327,12 @@ macro(git_get_versioninfo source_root_directory)
WORKING_DIRECTORY ${source_root_directory}
RESULT_VARIABLE _rc)
if(_rc OR "${_git_trailing_commits}" STREQUAL "")
message(
FATAL_ERROR
"Please install latest version of git (`rev-list --count ${_git_last_vtag}..HEAD` failed)"
)
message(FATAL_ERROR "Please install latest version of git (`rev-list --count ${_git_last_vtag}..HEAD` failed)")
endif()
endif()
endmacro(git_get_versioninfo)
macro(semver_provide name source_root_directory build_directory_for_json_output
build_metadata parent_scope)
macro(semver_provide name source_root_directory build_directory_for_json_output build_metadata parent_scope)
set(_semver "")
set(_git_describe "")
set(_git_timestamp "")
@ -395,11 +352,9 @@ macro(semver_provide name source_root_directory build_directory_for_json_output
RESULT_VARIABLE _rc)
if(_rc OR "${_git_root}" STREQUAL "")
if(EXISTS "${source_root_directory}/.git")
message(ERROR
"`git rev-parse --show-toplevel` failed '${_git_root_error}'")
message(ERROR "`git rev-parse --show-toplevel` failed '${_git_root_error}'")
else()
message(VERBOSE
"`git rev-parse --show-toplevel` failed '${_git_root_error}'")
message(VERBOSE "`git rev-parse --show-toplevel` failed '${_git_root_error}'")
endif()
else()
set(_source_root "${source_root_directory}")
@ -420,8 +375,7 @@ macro(semver_provide name source_root_directory build_directory_for_json_output
set(_version_from "${source_root_directory}/VERSION.json")
if(CMAKE_VERSION VERSION_LESS 3.19)
message(
FATAL_ERROR "Требуется CMake версии >= 3.19 для чтения VERSION.json")
message(FATAL_ERROR "Требуется CMake версии >= 3.19 для чтения VERSION.json")
endif()
file(
STRINGS "${_version_from}" _versioninfo_json NEWLINE_CONSUME
@ -435,14 +389,11 @@ macro(semver_provide name source_root_directory build_directory_for_json_output
string(JSON _semver GET "${_versioninfo_json}" "semver")
unset(_json_object)
if(NOT _semver)
message(
FATAL_ERROR
"Unable to retrieve ${name} version from \"${_version_from}\" file.")
message(FATAL_ERROR "Unable to retrieve ${name} version from \"${_version_from}\" file.")
endif()
semver_parse("${_semver}")
if(NOT _semver_ok)
message(
FATAL_ERROR "SemVer `${_semver}` from ${_version_from}: ${_semver_err}")
message(FATAL_ERROR "SemVer `${_semver}` from ${_version_from}: ${_semver_err}")
endif()
elseif(_git_root AND _source_root STREQUAL _git_root)
set(_version_from git)
@ -551,8 +502,7 @@ macro(semver_provide name source_root_directory build_directory_for_json_output
\"semver\" : \"@_semver@\"\n}"
_versioninfo_json
@ONLY ESCAPE_QUOTES)
file(WRITE "${build_directory_for_json_output}/VERSION.json"
"${_versioninfo_json}")
file(WRITE "${build_directory_for_json_output}/VERSION.json" "${_versioninfo_json}")
endif()
endmacro(semver_provide)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2020-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru>
# Copyright (c) 2020-2024 Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> ###############################################
# SPDX-License-Identifier: Apache-2.0
enable_language(CXX)
@ -8,14 +8,10 @@ function(add_extra_test name)
set(options DISABLED)
set(oneValueArgs TIMEOUT)
set(multiValueArgs SOURCE LIBRARY DEPEND DLLPATH)
cmake_parse_arguments(params "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
cmake_parse_arguments(params "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(params_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR
"Unknown keywords given to add_extra_test(): \"${params_UNPARSED_ARGUMENTS}\"."
)
message(FATAL_ERROR "Unknown keywords given to add_extra_test(): \"${params_UNPARSED_ARGUMENTS}\".")
endif()
macro(oops)
@ -30,12 +26,10 @@ function(add_extra_test name)
add_executable(${target} ${params_SOURCE})
target_include_directories(${target} PRIVATE "${PROJECT_SOURCE_DIR}")
target_link_libraries(${target} ${TOOL_MDBX_LIB})
set_target_properties(${target} PROPERTIES SKIP_BUILD_RPATH FALSE
BUILD_WITH_INSTALL_RPATH FALSE)
set_target_properties(${target} PROPERTIES SKIP_BUILD_RPATH FALSE BUILD_WITH_INSTALL_RPATH FALSE)
if(MDBX_BUILD_CXX AND MDBX_CXX_STANDARD)
set_target_properties(${target} PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON)
set_target_properties(${target} PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
endif()
if(params_DEPEND)
@ -47,32 +41,25 @@ function(add_extra_test name)
foreach(dep IN LISTS params_LIBRARY)
get_target_property(type ${dep} TYPE)
if(type STREQUAL SHARED_LIBRARY)
# Windows don't have RPATH feature, therefore we should prepare PATH or
# copy DLL(s)...
# Windows don't have RPATH feature, therefore we should prepare PATH or copy DLL(s)...
if(CMAKE_CONFIGURATION_TYPES)
# Could not provide static ENVIRONMENT property with
# configuration-depended path
# Could not provide static ENVIRONMENT property with configuration-depended path
set(dir FALSE)
else(CMAKE_CONFIGURATION_TYPES)
get_target_property(filename ${dep}
IMPORTED_LOCATION_${CMAKE_BUILD_TYPE_UPPERCASE})
get_target_property(filename ${dep} IMPORTED_LOCATION_${CMAKE_BUILD_TYPE_UPPERCASE})
if(NOT filename)
get_target_property(filename ${dep} IMPORTED_LOCATION)
endif()
get_target_property(filename ${dep}
LOCATION_${CMAKE_BUILD_TYPE_UPPERCASE})
get_target_property(filename ${dep} LOCATION_${CMAKE_BUILD_TYPE_UPPERCASE})
if(NOT filename)
get_target_property(filename ${dep} LOCATION)
endif()
if(filename)
get_filename_component(dir ${filename} DIRECTORY)
else(filename)
get_target_property(
dir ${dep} LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE_UPPERCASE})
get_target_property(dir ${dep} LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE_UPPERCASE})
if(NOT dir)
get_target_property(
dir ${dep}
RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE_UPPERCASE})
get_target_property(dir ${dep} RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE_UPPERCASE})
endif()
if(NOT dir)
get_target_property(dir ${dep} LIBRARY_OUTPUT_DIRECTORY)
@ -89,32 +76,25 @@ function(add_extra_test name)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
if exist "$<TARGET_PDB_FILE:${dep}>" ${CMAKE_COMMAND} -E
copy_if_different "$<TARGET_PDB_FILE:${dep}>"
"$<TARGET_FILE_DIR:${target}>")
COMMAND if exist "$<TARGET_PDB_FILE:${dep}>" ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_PDB_FILE:${dep}>" "$<TARGET_FILE_DIR:${target}>")
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:${dep}>" "$<TARGET_FILE_DIR:${target}>"
COMMENT
"${TOOL_MDBX_DLLCRUTCH}: Copy shared library ${dep} for test ${target}"
)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${dep}>" "$<TARGET_FILE_DIR:${target}>"
COMMENT "${TOOL_MDBX_DLLCRUTCH}: Copy shared library ${dep} for test ${target}")
endif(dir)
endif()
endforeach(dep)
endif(TOOL_MDBX_DLLCRUTCH)
if(NOT params_DISABLED AND NOT (CMAKE_CROSSCOMPILING
AND NOT CMAKE_CROSSCOMPILING_EMULATOR))
if(NOT params_DISABLED AND NOT (CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR))
add_test(extra_${name} ${MDBX_OUTPUT_DIR}/${target})
if(params_TIMEOUT)
if(MEMORYCHECK_COMMAND
OR CMAKE_MEMORYCHECK_COMMAND
OR ENABLE_MEMCHECK)
# FIXME: unless there are any other ideas how to fix the timeouts
# problem when testing under Valgrind.
# FIXME: unless there are any other ideas how to fix the timeouts problem when testing under Valgrind.
math(EXPR params_TIMEOUT "${params_TIMEOUT} * 42")
endif()
set_tests_properties(extra_${name} PROPERTIES TIMEOUT ${params_TIMEOUT})
@ -133,8 +113,7 @@ function(add_extra_test name)
else()
string(REPLACE ";" ":" params_DLLPATH_ENV "${params_DLLPATH_ENV}")
endif()
set_tests_properties(extra_${name}
PROPERTIES ENVIRONMENT "PATH=${params_DLLPATH_ENV}")
set_tests_properties(extra_${name} PROPERTIES ENVIRONMENT "PATH=${params_DLLPATH_ENV}")
endif()
endif()
endfunction(add_extra_test)
@ -179,13 +158,10 @@ add_executable(mdbx_test ${LIBMDBX_TEST_SOURCES})
target_compile_definitions(mdbx_test PRIVATE MDBX_BUILD_TEST=1 MDBX_BUILD_CXX=1)
if(MDBX_CXX_STANDARD)
set_target_properties(mdbx_test PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON)
set_target_properties(mdbx_test PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
endif()
set_target_properties(
mdbx_test PROPERTIES INTERPROCEDURAL_OPTIMIZATION
$<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
set_target_properties(mdbx_test PROPERTIES INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
target_setup_options(mdbx_test)
if(NOT MDBX_BUILD_CXX)
@ -205,8 +181,7 @@ if(NOT MDBX_BUILD_CXX AND LIBCXX_FILESYSTEM)
endif()
if(CMAKE_VERSION VERSION_LESS 3.1)
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH}
${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} ${CMAKE_THREAD_LIBS_INIT})
else()
target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} Threads::Threads)
endif()
@ -222,29 +197,22 @@ if(NOT SUBPROJECT)
endif()
endif()
# ##############################################################################
# ######################################################################################################################
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
message(WARNING "No emulator to run cross-compiled tests")
add_test(NAME fake_since_no_crosscompiling_emulator
COMMAND ${CMAKE_COMMAND} -E echo
"No emulator to run cross-compiled tests")
add_test(NAME fake_since_no_crosscompiling_emulator COMMAND ${CMAKE_COMMAND} -E echo
"No emulator to run cross-compiled tests")
else()
string(
RANDOM
LENGTH 9
ALPHABET "1234567890" test_seed)
message(
STATUS
"The ${test_seed} will be used for seeding tests. Re-run cmake to re-seed it."
)
message(STATUS "The ${test_seed} will be used for seeding tests. Re-run cmake to re-seed it.")
add_test(
NAME smoke
COMMAND
${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=verbose --prng-seed=${test_seed}
--progress --console=no --pathname=smoke.db --dont-cleanup-after basic)
add_test(NAME smoke COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=verbose --prng-seed=${test_seed} --progress
--console=no --pathname=smoke.db --dont-cleanup-after basic)
set_tests_properties(smoke PROPERTIES TIMEOUT 600 RUN_SERIAL OFF)
if(MDBX_BUILD_TOOLS)
add_test(NAME smoke_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv smoke.db)
@ -258,8 +226,7 @@ else()
"cooperative mode"
REQUIRED_FILES
smoke.db)
add_test(NAME smoke_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv
smoke.db-copy)
add_test(NAME smoke_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv smoke.db-copy)
set_tests_properties(
smoke_chk_copy
PROPERTIES DEPENDS
@ -275,19 +242,14 @@ else()
add_test(
NAME dupsort_writemap
COMMAND
${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=notice --prng-seed=${test_seed}
--table=+data.fixed --keygen.split=29 --datalen=rnd --progress
--console=no --repeat=2 --pathname=dupsort_writemap.db
--dont-cleanup-after basic)
${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=notice --prng-seed=${test_seed} --table=+data.fixed --keygen.split=29
--datalen=rnd --progress --console=no --repeat=2 --pathname=dupsort_writemap.db --dont-cleanup-after basic)
set_tests_properties(dupsort_writemap PROPERTIES TIMEOUT 3600 RUN_SERIAL OFF)
if(MDBX_BUILD_TOOLS)
add_test(NAME dupsort_writemap_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk
-nvvwc dupsort_writemap.db)
set_tests_properties(
dupsort_writemap_chk PROPERTIES DEPENDS dupsort_writemap TIMEOUT 60
REQUIRED_FILES dupsort_writemap.db)
add_test(NAME dupsort_writemap_chk_copy
COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvc dupsort_writemap.db-copy)
add_test(NAME dupsort_writemap_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvwc dupsort_writemap.db)
set_tests_properties(dupsort_writemap_chk PROPERTIES DEPENDS dupsort_writemap TIMEOUT 60 REQUIRED_FILES
dupsort_writemap.db)
add_test(NAME dupsort_writemap_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvc dupsort_writemap.db-copy)
set_tests_properties(
dupsort_writemap_chk_copy
PROPERTIES DEPENDS
@ -300,16 +262,12 @@ else()
dupsort_writemap.db-copy)
endif()
add_test(
NAME uniq_nested
COMMAND
${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=notice
--mode=-writemap,-nosync-safe,-lifo --progress --console=no --repeat=2
--pathname=uniq_nested.db --dont-cleanup-after basic)
add_test(NAME uniq_nested
COMMAND ${MDBX_OUTPUT_DIR}/mdbx_test --loglevel=notice --mode=-writemap,-nosync-safe,-lifo --progress
--console=no --repeat=2 --pathname=uniq_nested.db --dont-cleanup-after basic)
set_tests_properties(uniq_nested PROPERTIES TIMEOUT 1800 RUN_SERIAL OFF)
if(MDBX_BUILD_TOOLS)
add_test(NAME uniq_nested_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvw
uniq_nested.db)
add_test(NAME uniq_nested_chk COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvvw uniq_nested.db)
set_tests_properties(
uniq_nested_chk
PROPERTIES DEPENDS
@ -320,8 +278,7 @@ else()
"cooperative mode"
REQUIRED_FILES
uniq_nested.db)
add_test(NAME uniq_nested_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv
uniq_nested.db-copy)
add_test(NAME uniq_nested_chk_copy COMMAND ${MDBX_OUTPUT_DIR}/mdbx_chk -nvv uniq_nested.db-copy)
set_tests_properties(
uniq_nested_chk_copy
PROPERTIES DEPENDS