mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
V2.x no std format (#3271)
* Removed SPDLOG_USE_STD_FORMAT * Removed SPDLOG_USE_STD_FORMAT * clang-format * Fix windows.yml ci * Fix ci
This commit is contained in:
@@ -34,7 +34,6 @@ elseif(CMAKE_CXX_STANDARD LESS 17)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR CMAKE_SYSTEM_NAME MATCHES "MINGW")
|
||||
@@ -58,7 +57,6 @@ option(SPDLOG_BUILD_ALL "Build all artifacts" OFF)
|
||||
# build shared option
|
||||
option(SPDLOG_BUILD_SHARED "Build shared library" OFF)
|
||||
|
||||
|
||||
# example options
|
||||
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT})
|
||||
|
||||
@@ -77,19 +75,9 @@ option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" OFF)
|
||||
# install options
|
||||
option(SPDLOG_SYSTEM_INCLUDES "Include as system headers (skip for clang-tidy)." OFF)
|
||||
option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT})
|
||||
option(SPDLOG_USE_STD_FORMAT "Use std::format instead of fmt library." OFF)
|
||||
option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of of fetching from gitub." OFF)
|
||||
|
||||
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
|
||||
|
||||
if(SPDLOG_USE_STD_FORMAT AND CMAKE_CXX_STANDARD LESS 20)
|
||||
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT must be used with CMAKE_CXX_STANDARD >= 20")
|
||||
endif()
|
||||
|
||||
if(SPDLOG_USE_STD_FORMAT AND SPDLOG_FMT_EXTERNAL)
|
||||
message(FATAL_ERROR "SPDLOG_USE_STD_FORMAT and SPDLOG_FMT_EXTERNAL are mutually exclusive")
|
||||
endif()
|
||||
|
||||
# misc tweakme options
|
||||
if(WIN32)
|
||||
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
|
||||
@@ -126,35 +114,31 @@ if(SPDLOG_BUILD_SHARED)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# place dlls and libs and executables in the same directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
# place dlls and libs and executables in the same directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
|
||||
|
||||
# make sure __cplusplus is defined
|
||||
add_compile_options(/Zc:__cplusplus)
|
||||
# enable parallel build for the solution
|
||||
add_compile_options(/MP)
|
||||
# make sure __cplusplus is defined
|
||||
add_compile_options(/Zc:__cplusplus)
|
||||
# enable parallel build for the solution
|
||||
add_compile_options(/MP)
|
||||
endif()
|
||||
|
||||
|
||||
message(STATUS "spdlog version: ${SPDLOG_VERSION}")
|
||||
message(STATUS "spdlog build type: " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "spdlog build shared: " ${BUILD_SHARED_LIBS})
|
||||
message(STATUS "spdlog use std format: " ${SPDLOG_USE_STD_FORMAT})
|
||||
message(STATUS "spdlog fmt external: " ${SPDLOG_FMT_EXTERNAL})
|
||||
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Find {fmt} library if not using std::format
|
||||
# Find {fmt} library
|
||||
# ---------------------------------------------------------------------------------------
|
||||
if(NOT SPDLOG_USE_STD_FORMAT)
|
||||
if (SPDLOG_FMT_EXTERNAL)
|
||||
find_package(fmt REQUIRED)
|
||||
message(STATUS "Using external fmt lib version: ${fmt_VERSION}")
|
||||
else()
|
||||
include(cmake/fmtlib.cmake)
|
||||
endif()
|
||||
if(SPDLOG_FMT_EXTERNAL)
|
||||
find_package(fmt REQUIRED)
|
||||
message(STATUS "Using external fmt lib version: ${fmt_VERSION}")
|
||||
else()
|
||||
include(cmake/fmtlib.cmake)
|
||||
endif()
|
||||
|
||||
# ---------------------------------------------------------------------------------------
|
||||
@@ -217,8 +201,7 @@ set(SPDLOG_HEADERS
|
||||
"include/spdlog/sinks/syslog_sink.h"
|
||||
"include/spdlog/sinks/systemd_sink.h"
|
||||
"include/spdlog/sinks/tcp_sink.h"
|
||||
"include/spdlog/sinks/udp_sink.h"
|
||||
)
|
||||
"include/spdlog/sinks/udp_sink.h")
|
||||
|
||||
set(SPDLOG_SRCS
|
||||
"src/async_logger.cpp"
|
||||
@@ -242,20 +225,18 @@ set(SPDLOG_SRCS
|
||||
"src/sinks/stdout_sinks.cpp")
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SPDLOG_SRCS
|
||||
"src/details/os_windows.cpp"
|
||||
"src/sinks/wincolor_sink.cpp")
|
||||
list(APPEND SPDLOG_HEADERS
|
||||
"include/spdlog/details/tcp_client_windows.h"
|
||||
"include/spdlog/details/udp_client_windows.h"
|
||||
"include/spdlog/details/windows_include.h"
|
||||
"include/spdlog/sinks/win_eventlog_sink.h"
|
||||
"include/spdlog/sinks/wincolor_sink.h")
|
||||
list(APPEND SPDLOG_SRCS "src/details/os_windows.cpp" "src/sinks/wincolor_sink.cpp")
|
||||
list(
|
||||
APPEND
|
||||
SPDLOG_HEADERS
|
||||
"include/spdlog/details/tcp_client_windows.h"
|
||||
"include/spdlog/details/udp_client_windows.h"
|
||||
"include/spdlog/details/windows_include.h"
|
||||
"include/spdlog/sinks/win_eventlog_sink.h"
|
||||
"include/spdlog/sinks/wincolor_sink.h")
|
||||
else()
|
||||
list(APPEND SPDLOG_SRCS "src/details/os_unix.cpp")
|
||||
list(APPEND SPDLOG_HEADERS
|
||||
"include/spdlog/details/tcp_client_unix.h"
|
||||
"include/spdlog/details/udp_client_unix.h")
|
||||
list(APPEND SPDLOG_HEADERS "include/spdlog/details/tcp_client_unix.h" "include/spdlog/details/udp_client_unix.h")
|
||||
endif()
|
||||
|
||||
# Generate spdlog_config.h based on the current configuration
|
||||
@@ -287,16 +268,14 @@ endif()
|
||||
|
||||
set_target_properties(spdlog PROPERTIES PUBLIC_HEADER "${SPDLOG_HEADERS}")
|
||||
|
||||
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
|
||||
target_link_libraries(spdlog PUBLIC Threads::Threads)
|
||||
if(NOT SPDLOG_USE_STD_FORMAT)
|
||||
target_link_libraries(spdlog PUBLIC fmt::fmt)
|
||||
endif()
|
||||
target_link_libraries(spdlog PUBLIC fmt::fmt)
|
||||
spdlog_enable_warnings(spdlog)
|
||||
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR})
|
||||
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
|
||||
@@ -313,7 +292,6 @@ if(ANDROID)
|
||||
target_link_libraries(spdlog PUBLIC log)
|
||||
endif()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# If exceptions are disabled, disable them in the bundled fmt as well
|
||||
# ---------------------------------------------------------------------------------------
|
||||
@@ -403,8 +381,7 @@ if(SPDLOG_INSTALL)
|
||||
# ---------------------------------------------------------------------------------------
|
||||
include(cmake/spdlogCPack.cmake)
|
||||
|
||||
# Install spdlog_config.h file
|
||||
# Assume your tweakme.h.in is located in the same directory as CMakeLists.txt
|
||||
# Install spdlog_config.h file Assume your tweakme.h.in is located in the same directory as CMakeLists.txt
|
||||
set(TWEAKME_IN "${CMAKE_CURRENT_SOURCE_DIR}/tweakme.h.in")
|
||||
set(TWEAKME_OUT "${CMAKE_CURRENT_BINARY_DIR}/include/spdlog/tweakme.h")
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user