From f605f7a9c26ebd434da1cbd9ed9b294d05c96ee8 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 21 Jan 2025 21:53:39 +0000 Subject: [PATCH 1/2] build: refactor: set debug definitions in main CMakeLists No functional change. This is a simple move required the next commit. --- CMakeLists.txt | 9 +++++++++ cmake/module/ProcessConfigurations.cmake | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7fa35b9ecc..3812c207b5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,6 +235,15 @@ include(ProcessConfigurations) include(TryAppendCXXFlags) include(TryAppendLinkerFlag) +# Redefine/adjust per-configuration flags. +target_compile_definitions(core_interface_debug INTERFACE + DEBUG + DEBUG_LOCKORDER + DEBUG_LOCKCONTENTION + RPC_DOC_CHECK + ABORT_ON_FAILED_ASSUME +) + if(WIN32) #[=[ This build system supports two ways to build binaries for Windows. diff --git a/cmake/module/ProcessConfigurations.cmake b/cmake/module/ProcessConfigurations.cmake index 7e2fc0080e9..52fca3cd1f7 100644 --- a/cmake/module/ProcessConfigurations.cmake +++ b/cmake/module/ProcessConfigurations.cmake @@ -119,14 +119,6 @@ endfunction() set_default_config(RelWithDebInfo) -# Redefine/adjust per-configuration flags. -target_compile_definitions(core_interface_debug INTERFACE - DEBUG - DEBUG_LOCKORDER - DEBUG_LOCKCONTENTION - RPC_DOC_CHECK - ABORT_ON_FAILED_ASSUME -) # We leave assertions on. if(MSVC) remove_cxx_flag_from_all_configs(/DNDEBUG) From 56a9b847bba2b8deb6a9c3f3a7eb95b4c71c2d14 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 21 Jan 2025 22:11:26 +0000 Subject: [PATCH 2/2] build: set build type and per-build-type flags as early as possible With the exception of the first c++ checks, this ensures that compiler tests are never run with the wrong build type's flags. Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> --- CMakeLists.txt | 3 +-- cmake/module/ProcessConfigurations.cmake | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3812c207b5b..25325dd6f6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/module) +include(ProcessConfigurations) #============================= # Configurable options @@ -230,8 +231,6 @@ if(BUILD_FOR_FUZZING) ) endif() -include(ProcessConfigurations) - include(TryAppendCXXFlags) include(TryAppendLinkerFlag) diff --git a/cmake/module/ProcessConfigurations.cmake b/cmake/module/ProcessConfigurations.cmake index 52fca3cd1f7..9a510a00a55 100644 --- a/cmake/module/ProcessConfigurations.cmake +++ b/cmake/module/ProcessConfigurations.cmake @@ -4,8 +4,6 @@ include_guard(GLOBAL) -include(TryAppendCXXFlags) - macro(normalize_string string) string(REGEX REPLACE " +" " " ${string} "${${string}}") string(STRIP "${${string}}" ${string}) @@ -119,6 +117,8 @@ endfunction() set_default_config(RelWithDebInfo) +include(TryAppendCXXFlags) + # We leave assertions on. if(MSVC) remove_cxx_flag_from_all_configs(/DNDEBUG)