From 7b04c276899073a7c5a0fbabf2eff8dcbed5e971 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 11 Oct 2025 00:51:06 +0100 Subject: [PATCH] Add option to enable slog logging in CMake configuration --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0353ccd..4cf1123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,9 @@ ENDIF(APPLE) project(libaaruformat C) +# Option to enable slog logging (disabled by default) +option(USE_SLOG "Enable slog logging" OFF) + add_compile_definitions(__STDC_FORMAT_MACROS=1) if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" AND "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARMV7") @@ -200,16 +203,24 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) if(POLICY CMP0000) cmake_policy(VERSION 3.5) endif() -add_subdirectory(3rdparty/slog) + +# Conditionally enable slog logging +if(USE_SLOG) + add_subdirectory(3rdparty/slog) + + # Include slog headers + include_directories(aaruformat 3rdparty/slog/src) + + # Enable TRACE and slog output + add_compile_definitions(aaruformat ENABLE_TRACE ENABLE_FATAL USE_SLOG) + + message(STATUS "slog logging enabled") +else() + message(STATUS "slog logging disabled (enable with -DUSE_SLOG=ON)") +endif() include_directories(include 3rdparty/uthash/src) -# Include slog headers -include_directories(aaruformat 3rdparty/slog/src) - -# Enable TRACE and slog output -add_compile_definitions(aaruformat ENABLE_TRACE USE_SLOG) - include(CheckLibraryExists) check_library_exists(m log "" HAVE_LIB_M) @@ -217,8 +228,10 @@ if(HAVE_LIB_M) TARGET_LINK_LIBRARIES_WHOLE_ARCHIVE(aaruformat m) endif() -# Link slog -target_link_libraries(aaruformat slog) +# Link slog conditionally +if(USE_SLOG) + target_link_libraries(aaruformat slog) +endif() # Find Doxygen for documentation generation find_package(Doxygen)