Skip to content

Commit d715553

Browse files
authored
Added SPDLOG_FWRITE_UNLOCKED option to CMakeLists.txt (#3318)
* Added SPDLOG_FWRITE_UNLOCKED option to CMakeLists.txt * Update CMakeLists.txt
1 parent ad0f31c commit d715553

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
135135
option(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
138139
option(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()
253256
endif()
254257

255258
# ---------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)