From 3ccb44c43e2800ca33d38d654f9c0600e82020de Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Wed, 6 Sep 2023 12:41:33 +0200 Subject: [PATCH] cmake/re-config: add default CMAKE_BUILD_TYPE and fix RELEASE definition Empty CMAKE_BUILD_TYPE is not equal to Debug build and can lead to missing debug symbols. Since cmake also non build configurations it's better to set RELEASE definition by CONFIG generator expression. --- cmake/re-config.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/re-config.cmake b/cmake/re-config.cmake index fff919e17..53f4c3bb6 100644 --- a/cmake/re-config.cmake +++ b/cmake/re-config.cmake @@ -18,6 +18,12 @@ option(USE_OPENSSL "Enable OpenSSL" ${OPENSSL_FOUND}) option(USE_UNIXSOCK "Enable Unix Domain Sockets" ON) option(USE_TRACE "Enable Tracing helpers" OFF) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Debug' as none was specified.") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." + FORCE) +endif() + check_symbol_exists("arc4random" "stdlib.h" HAVE_ARC4RANDOM) if(HAVE_ARC4RANDOM) list(APPEND RE_DEFINITIONS -DHAVE_ARC4RANDOM) @@ -178,11 +184,10 @@ endif() list(APPEND RE_DEFINITIONS -DARCH="${CMAKE_SYSTEM_PROCESSOR}" -DOS="${CMAKE_SYSTEM_NAME}" + $<$>:-DRELEASE> ) -if(${CMAKE_BUILD_TYPE} MATCHES "[Rr]el") - list(APPEND RE_DEFINITIONS -DRELEASE) -else() +if(NOT ${CMAKE_BUILD_TYPE} MATCHES "[Rr]el") if(Backtrace_FOUND) set(CMAKE_ENABLE_EXPORTS ON) endif()