From 472b875990d4cb848785d64c922b68214bb07470 Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 12 Jan 2025 00:02:34 +0200 Subject: [PATCH] Added SPDLOG_FWRITE_UNLOCKED option to CMakeLists.txt --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e56c5699..d1f3ec4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,8 @@ option( OFF) option(SPDLOG_DISABLE_DEFAULT_LOGGER "Disable default logger creation" OFF) +option(SPDLOG_FWRITE_UNLOCKED "Use the unlocked variant of fwrite. Leave this on unless your libc doesn't have it" ON) + # clang-tidy option(SPDLOG_TIDY "run clang-tidy" OFF) @@ -241,15 +243,17 @@ endif() # --------------------------------------------------------------------------------------- # Check if fwrite_unlocked/_fwrite_nolock is available # --------------------------------------------------------------------------------------- -include(CheckSymbolExists) -if(WIN32) - check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED) -else () - check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED) -endif() -if(HAVE_FWRITE_UNLOCKED) - target_compile_definitions(spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED) - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED) +if(SPDLOG_FWRITE_UNLOCKED) + include(CheckSymbolExists) + if(WIN32) + check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED) + else () + check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED) + endif() + if(HAVE_FWRITE_UNLOCKED) + target_compile_definitions(spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED) + endif() endif() # ---------------------------------------------------------------------------------------