@@ -133,6 +133,7 @@ option(
133133 "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
134134 OFF )
135135option (SPDLOG_DISABLE_DEFAULT_LOGGER "Disable default logger creation" OFF )
136+ option (SPDLOG_FWRITE_UNLOCKED "Use the unlocked variant of fwrite. Leave this on unless your libc doesn't have it" ON )
136137
137138# clang-tidy
138139option (SPDLOG_TIDY "run clang-tidy" OFF )
@@ -241,15 +242,17 @@ endif()
241242# ---------------------------------------------------------------------------------------
242243# Check if fwrite_unlocked/_fwrite_nolock is available
243244# ---------------------------------------------------------------------------------------
244- include (CheckSymbolExists)
245- if (WIN32 )
246- check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
247- else ()
248- check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
249- endif ()
250- if (HAVE_FWRITE_UNLOCKED)
251- target_compile_definitions (spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED)
252- target_compile_definitions (spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED)
245+ if (SPDLOG_FWRITE_UNLOCKED)
246+ include (CheckSymbolExists)
247+ if (WIN32 )
248+ check_symbol_exists(_fwrite_nolock "stdio.h" HAVE_FWRITE_UNLOCKED)
249+ else ()
250+ check_symbol_exists(fwrite_unlocked "stdio.h" HAVE_FWRITE_UNLOCKED)
251+ endif ()
252+ if (HAVE_FWRITE_UNLOCKED)
253+ target_compile_definitions (spdlog PRIVATE SPDLOG_FWRITE_UNLOCKED)
254+ target_compile_definitions (spdlog_header_only INTERFACE SPDLOG_FWRITE_UNLOCKED)
255+ endif ()
253256endif ()
254257
255258# ---------------------------------------------------------------------------------------
0 commit comments