From 10c50aaf2e4d8fe858dc8be941f122b5ed0565de Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 28 Sep 2020 23:47:37 +0300 Subject: [PATCH] mdbx-cmake: minor refine MDBX_BUILD_TARGET/MDBX_BUILD_TYPE, etc. Change-Id: I34f99c50ced56b310576743c56422a1e1992c03b --- CMakeLists.txt | 11 ++++++----- src/config.h.in | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5512817..24c20501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ if(MDBX_AMALGAMATED_SOURCE AND DEFINED MDBX_ENABLE_TESTS AND MDBX_ENABLE_TESTS) endif() # Try to find a C++ compiler unless sure that this is unnecessary. -if (NOT CMAKE_CXX_COMPILER) +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))) @@ -456,7 +456,7 @@ else() unset(MDBX_LINK_TOOLS_NONSTATIC CACHE) endif() -if(CMAKE_CXX_COMPILER AND MDBX_CXX_STANDARD GREATER_EQUAL 11 AND MDBX_CXX_STANDARD LESS 83) +if(CMAKE_CXX_COMPILER_LOADED AND MDBX_CXX_STANDARD GREATER_EQUAL 11 AND MDBX_CXX_STANDARD LESS 83) if(NOT MDBX_AMALGAMATED_SOURCE) option(MDBX_ENABLE_TESTS "Build MDBX tests" ${BUILD_TESTING}) endif() @@ -476,7 +476,7 @@ endif() ################################################################################ ################################################################################ -if(MDBX_BUILD_CXX AND NOT CMAKE_CXX_COMPILER) +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.") endif() @@ -788,13 +788,14 @@ endif() # provide build-type if(CMAKE_CONFIGURATION_TYPES) + # via per-configuration define add_definitions(-DMDBX_BUILD_TYPE="$") else() set(MDBX_BUILD_TYPE ${CMAKE_BUILD_TYPE}) endif() # options -set(options VERSION C_COMPILER CXX_COMPILER) +set(options VERSION C_COMPILER CXX_COMPILER MDBX_BUILD_TARGET MDBX_BUILD_TYPE) foreach(item IN LISTS options) if(DEFINED ${item}) set(value "${${item}}") @@ -818,7 +819,7 @@ 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) + if(NOT CMAKE_CXX_COMPILER_LOADED) message(FATAL_ERROR "MDBX_ENABLE_TESTS=${MDBX_ENABLE_TESTS}: The C++ compiler is required to build the tests.") endif() add_subdirectory(test) diff --git a/src/config.h.in b/src/config.h.in index 414ac9e9..5048d4e0 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -42,11 +42,21 @@ #endif /* Build Info */ +#ifndef MDBX_BUILD_TIMESTAMP #cmakedefine MDBX_BUILD_TIMESTAMP "@MDBX_BUILD_TIMESTAMP@" +#endif +#ifndef MDBX_BUILD_TARGET #cmakedefine MDBX_BUILD_TARGET "@MDBX_BUILD_TARGET@" +#endif +#ifndef MDBX_BUILD_TYPE #cmakedefine MDBX_BUILD_TYPE "@MDBX_BUILD_TYPE@" +#endif +#ifndef MDBX_BUILD_COMPILER #cmakedefine MDBX_BUILD_COMPILER "@MDBX_BUILD_COMPILER@" +#endif +#ifndef MDBX_BUILD_FLAGS #cmakedefine MDBX_BUILD_FLAGS "@MDBX_BUILD_FLAGS@" +#endif #cmakedefine MDBX_BUILD_SOURCERY @MDBX_BUILD_SOURCERY@ /* *INDENT-ON* */