From e6cddd1028cd4610698b64dfe4816897d4dcb4ad Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 30 Nov 2024 18:46:28 +0200 Subject: [PATCH] Update cmakelists and config.h --- CMakeLists.txt | 33 +++++++++++++++++++++------------ cmake/spdlog_config.h.in | 2 ++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80248c9d..e4ea842f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,11 +232,30 @@ else() list(APPEND SPDLOG_HEADERS "include/spdlog/details/tcp_client_unix.h" "include/spdlog/details/udp_client_unix.h") 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) + set(SPDLOG_FWRITE_UNLOCKED 1) +endif() + +# --------------------------------------------------------------------------------------- # Generate spdlog_config.h based on the current configuration +# --------------------------------------------------------------------------------------- set(OUT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/spdlog/spdlog_config.h") message(STATUS "Generating ${OUT_CONFIG_FILE}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/spdlog_config.h.in" ${OUT_CONFIG_FILE} @ONLY) list(APPEND SPDLOG_HEADERS ${OUT_CONFIG_FILE}) + +# --------------------------------------------------------------------------------------- +# spdlog library +# --------------------------------------------------------------------------------------- if(BUILD_SHARED_LIBS) if(WIN32) set(VERSION_RC ${CMAKE_CURRENT_BINARY_DIR}/version.rc) @@ -271,25 +290,15 @@ set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR}) set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d) +# --------------------------------------------------------------------------------------- # set source groups for visual studio +# --------------------------------------------------------------------------------------- if(CMAKE_GENERATOR MATCHES "Visual Studio") source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include PREFIX include FILES ${SPDLOG_HEADERS}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX sources FILES ${SPDLOG_SRCS}) source_group(sources FILES ${VERSION_RC}) 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) -endif() # --------------------------------------------------------------------------------------- # Add required libraries for Android CMake build # --------------------------------------------------------------------------------------- diff --git a/cmake/spdlog_config.h.in b/cmake/spdlog_config.h.in index 617692e4..1148ed92 100644 --- a/cmake/spdlog_config.h.in +++ b/cmake/spdlog_config.h.in @@ -27,3 +27,5 @@ // Use external fmtlib instead of bundled #cmakedefine SPDLOG_FMT_EXTERNAL + +#cmakedefine SPDLOG_FWRITE_UNLOCKED