Allow disabling isleapp debugging by configuring with -DISLE_DEBUG=OFF

This commit is contained in:
Anonymous Maarten 2025-05-20 23:28:06 +02:00
parent 7c0c45d630
commit d5f9ffff01
3 changed files with 25 additions and 2 deletions

View File

@ -22,6 +22,7 @@ option(ISLE_BUILD_APP "Build isle application" ON)
option(ISLE_ASAN "Enable Address Sanitizer" OFF) option(ISLE_ASAN "Enable Address Sanitizer" OFF)
option(ISLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF) option(ISLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF)
option(ISLE_WERROR "Treat warnings as errors" OFF) option(ISLE_WERROR "Treat warnings as errors" OFF)
option(ISLE_DEBUG "Enable imgui debug" ON)
cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF)
cmake_dependent_option(ISLE_MINIWIN "Use miniwin and minimfc" ON "NOT ISLE_USE_DX5" OFF) cmake_dependent_option(ISLE_MINIWIN "Use miniwin and minimfc" ON "NOT ISLE_USE_DX5" OFF)
cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN" OFF) cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN" OFF)
@ -34,6 +35,7 @@ message(STATUS "Isle app: ${ISLE_BUILD_APP}")
message(STATUS "Config app: ${ISLE_BUILD_CONFIG}") message(STATUS "Config app: ${ISLE_BUILD_CONFIG}")
message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}") message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}")
message(STATUS "Internal miniwin: ${ISLE_MINIWIN}") message(STATUS "Internal miniwin: ${ISLE_MINIWIN}")
message(STATUS "Isle debugging: ${ISLE_DEBUG}")
if (DOWNLOAD_DEPENDENCIES) if (DOWNLOAD_DEPENDENCIES)
# FetchContent downloads and configures dependencies # FetchContent downloads and configures dependencies
@ -468,7 +470,6 @@ if (ISLE_BUILD_APP)
add_executable(isle WIN32 add_executable(isle WIN32
ISLE/res/isle.rc ISLE/res/isle.rc
ISLE/isleapp.cpp ISLE/isleapp.cpp
ISLE/isledebug.cpp
) )
list(APPEND isle_targets isle) list(APPEND isle_targets isle)
if (WIN32) if (WIN32)
@ -492,8 +493,14 @@ if (ISLE_BUILD_APP)
endif() endif()
# Link LEGO1 # Link LEGO1
target_link_libraries(isle PRIVATE lego1) target_link_libraries(isle PRIVATE lego1)
if(ISLE_DEBUG)
target_sources(isle PRIVATE
ISLE/isledebug.cpp
)
target_compile_definitions(isle PRIVATE ISLE_DEBUG)
target_link_libraries(isle PRIVATE imgui) target_link_libraries(isle PRIVATE imgui)
endif() endif()
endif()
if (ISLE_BUILD_CONFIG) if (ISLE_BUILD_CONFIG)
add_executable(config WIN32 add_executable(config WIN32

View File

@ -843,10 +843,12 @@ MxResult IsleApp::ParseArguments(int argc, char** argv)
m_iniPath = argv[i + 1]; m_iniPath = argv[i + 1];
consumed = 2; consumed = 2;
} }
#ifdef ISLE_DEBUG
else if (strcmp(argv[i], "--debug") == 0) { else if (strcmp(argv[i], "--debug") == 0) {
g_debugEnabled = true; g_debugEnabled = true;
consumed = 1; consumed = 1;
} }
#endif
if (consumed <= 0) { if (consumed <= 0) {
SDL_Log("Invalid argument(s): %s", argv[i]); SDL_Log("Invalid argument(s): %s", argv[i]);
return FAILURE; return FAILURE;

View File

@ -1,6 +1,8 @@
#ifndef ISLEDEBUG_H #ifndef ISLEDEBUG_H
#define ISLEDEBUG_H #define ISLEDEBUG_H
#if defined(ISLE_DEBUG)
extern bool g_debugEnabled; extern bool g_debugEnabled;
typedef union SDL_Event SDL_Event; typedef union SDL_Event SDL_Event;
@ -11,4 +13,16 @@ extern bool IsleDebug_Event(SDL_Event* event);
extern void IsleDebug_Render(); extern void IsleDebug_Render();
#else
#define IsleDebug_Init() do {} while (0)
#define IsleDebug_Event(EVENT) false
#define IsleDebug_Render() do {} while (0)
#define g_debugEnabled false
#endif
#endif #endif