diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a1b484..141dc96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,8 +60,9 @@ INCLUDE(${CMAKE_ROOT}/Modules/GNUInstallDirs.cmake) INCLUDE(${CMAKE_MODULE_PATH}/MarsNweInstallDirs.cmake) # Add options for build -option(ENABLE_DEBUG "Should we build with Debug?" ON) -option(ENABLE_DEBUG_DOSUTILS "Should we build with Mars Nwe Dosutils Debugging?" OFF) +option(ENABLE_DEBUG "Compile in MARS NWE debug logging code (DO_DEBUG)" OFF) +option(ENABLE_DEBUG_BUILD "Build with debug compiler flags (-g3 -O0 -fno-omit-frame-pointer)" OFF) +option(ENABLE_DEBUG_DOSUTILS "Enable NCP 17/02 debugging support for mars_dosutils" OFF) option(ENABLE_INTERNAL_RIP_SAP "Should we build Mars Nwe with Internal Router?" ON) option(ENABLE_SHADOW_PWD "Should we build Mars Nwe with Shadow Password Support?" ON) option(ENABLE_QUOTA_SUPPORT "Should we build Mars Nwe with Quota Support?" ON) @@ -72,6 +73,28 @@ option(MARS_NWE_BUILD_DOSUTILS "Build DOS client utilities with Open Watcom" OFF set(MARS_NWE_SMART_ADMIN_GROUP "root" CACHE STRING "Unix group allowed to log in to the SMArT/nwwebui admin interface") + +# ENABLE_DEBUG controls the legacy DO_DEBUG code paths used by XDPRINTF(). +# ENABLE_DEBUG_BUILD is separate and only changes compiler flags / build type. +# This allows release builds with compiled-in Mars debug logging, and also +# explicit -g/-O0 builds when debugging the server with gdb or valgrind. +if(ENABLE_DEBUG_BUILD) + if(NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) + endif() + + add_compile_options( + $<$:-g3> + $<$:-O0> + $<$:-fno-omit-frame-pointer> + ) +endif() + +if(NOT CMAKE_CONFIGURATION_TYPES) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "RelWithDebInfo" "MinSizeRel") +endif() + IF (ENABLE_DEBUG) SET (MARS_NWE_DEBUG "1") ELSE (ENABLE_DEBUG)