Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ endif ()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/support/cmake")

include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(JoinPaths)

if (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
Expand Down Expand Up @@ -307,6 +308,21 @@ else ()
message(WARNING "Feature cxx_std_11 is unknown for the CXX compiler")
endif ()

check_cxx_source_compiles(
[[
#include <stdio.h>
int main() {
// Use stdout just to prove we can pass a FILE* to it
flockfile(stdout);
funlockfile(stdout);
return 0;
}
]]
HAVE_FLOCKFILE_COMPILE_TEST)
target_compile_definitions(
fmt
PRIVATE FMT_HAVE_FLOCKFILE_COMPILE_TEST=$<BOOL:HAVE_FLOCKFILE_COMPILE_TEST>)

# Set FMT_LIB_NAME for pkg-config fmt.pc. We cannot use the OUTPUT_NAME target
# property because it's not set by default.
set(FMT_LIB_NAME fmt)
Expand Down
6 changes: 5 additions & 1 deletion include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,11 @@ template <typename F> auto getc_unlocked(F* f) -> decltype(_fgetc_nolock(f)) {
#endif

#ifndef FMT_USE_FLOCKFILE
# define FMT_USE_FLOCKFILE 1
# ifdef FMT_HAVE_FLOCKFILE_COMPILE_TEST
# define FMT_USE_FLOCKFILE FMT_HAVE_FLOCKFILE_COMPILE_TEST
# else
# define FMT_USE_FLOCKFILE 1
# endif
#endif

template <typename F = FILE, typename Enable = void>
Expand Down
Loading