From bdc6163b887ed0a979dc5ed54b334ac2babe2295 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 28 Nov 2021 06:26:57 +0300 Subject: [PATCH 1/2] Fix magic_enum for debug helpers --- base/base/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/base/base/CMakeLists.txt b/base/base/CMakeLists.txt index 281374b7121..000233738f7 100644 --- a/base/base/CMakeLists.txt +++ b/base/base/CMakeLists.txt @@ -29,7 +29,8 @@ elseif (ENABLE_READLINE) endif () if (USE_DEBUG_HELPERS) - set (INCLUDE_DEBUG_HELPERS "-include \"${ClickHouse_SOURCE_DIR}/base/base/iostream_debug_helpers.h\"") + get_target_property(MAGIC_ENUM_INCLUDE_DIR magic_enum INTERFACE_INCLUDE_DIRECTORIES) + set (INCLUDE_DEBUG_HELPERS "-I\"${MAGIC_ENUM_INCLUDE_DIR}\" -include \"${ClickHouse_SOURCE_DIR}/base/base/iostream_debug_helpers.h\"") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}") endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 031c849bef1..b098a478c9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,8 @@ configure_file (Common/config_version.h.in ${CONFIG_VERSION}) configure_file (Core/config_core.h.in "${CMAKE_CURRENT_BINARY_DIR}/Core/include/config_core.h") if (USE_DEBUG_HELPERS) - set (INCLUDE_DEBUG_HELPERS "-I\"${ClickHouse_SOURCE_DIR}/base\" -include \"${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h\"") + get_target_property(MAGIC_ENUM_INCLUDE_DIR magic_enum INTERFACE_INCLUDE_DIRECTORIES) + set (INCLUDE_DEBUG_HELPERS "-I\"${ClickHouse_SOURCE_DIR}/base\" -I\"${MAGIC_ENUM_INCLUDE_DIR}\" -include \"${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h\"") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}") endif () From f443dbf6e0f631f81a2810446e72cb0497f64374 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 28 Nov 2021 06:54:37 +0300 Subject: [PATCH 2/2] Enable debug helpers by default in debug builds --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b855213b365..ad54424571e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,6 +276,13 @@ if (NOT CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE") endif () endif() +if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG") + set(USE_DEBUG_HELPERS ON) +else () + set(USE_DEBUG_HELPERS ON) +endif() +option(USE_DEBUG_HELPERS "Enable debug helpers" ${USE_DEBUG_HELPERS}) + # Create BuildID when using lld. For other linkers it is created by default. if (LINKER_NAME MATCHES "lld$") # SHA1 is not cryptographically secure but it is the best what lld is offering.