clang-format
This commit is contained in:
parent
ea896885cd
commit
b0e836b000
@ -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})
|
||||
|
||||
@ -80,7 +78,6 @@ option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT})
|
||||
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)
|
||||
|
||||
|
||||
# misc tweakme options
|
||||
if(WIN32)
|
||||
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
|
||||
@ -117,19 +114,18 @@ 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})
|
||||
@ -138,7 +134,7 @@ message(STATUS "spdlog fmt external: " ${SPDLOG_FMT_EXTERNAL})
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# Find {fmt} library
|
||||
# ---------------------------------------------------------------------------------------
|
||||
if (SPDLOG_FMT_EXTERNAL)
|
||||
if(SPDLOG_FMT_EXTERNAL)
|
||||
find_package(fmt REQUIRED)
|
||||
message(STATUS "Using external fmt lib version: ${fmt_VERSION}")
|
||||
else()
|
||||
@ -205,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"
|
||||
@ -230,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
|
||||
@ -275,14 +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)
|
||||
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
|
||||
@ -299,7 +292,6 @@ if(ANDROID)
|
||||
target_link_libraries(spdlog PUBLIC log)
|
||||
endif()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------
|
||||
# If exceptions are disabled, disable them in the bundled fmt as well
|
||||
# ---------------------------------------------------------------------------------------
|
||||
@ -389,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()
|
||||
|
@ -22,7 +22,7 @@ if(NOT benchmark_FOUND)
|
||||
# Do not build and run googlebenchmark tests
|
||||
FetchContent_Declare(googlebenchmark GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.6.0)
|
||||
FetchContent_MakeAvailable(googlebenchmark)
|
||||
set_target_properties(benchmark PROPERTIES FOLDER "third-party")
|
||||
set_target_properties(benchmark PROPERTIES FOLDER "third-party")
|
||||
endif()
|
||||
|
||||
add_executable(bench bench.cpp)
|
||||
|
@ -6,19 +6,19 @@
|
||||
//
|
||||
// bench.cpp : spdlog benchmarks
|
||||
//
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/daily_file_sink.h"
|
||||
#include "spdlog/sinks/null_sink.h"
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdlib> // EXIT_FAILURE
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/daily_file_sink.h"
|
||||
#include "spdlog/sinks/null_sink.h"
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils.h"
|
||||
|
||||
void bench(int howmany, std::shared_ptr<spdlog::logger> log);
|
||||
|
@ -1,15 +1,13 @@
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
fmt
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
|
||||
URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz
|
||||
URL_HASH SHA256=6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f)
|
||||
fmt DOWNLOAD_EXTRACT_TIMESTAMP FALSE URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz
|
||||
URL_HASH SHA256=6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f)
|
||||
FetchContent_GetProperties(fmt)
|
||||
if(NOT fmt_POPULATED)
|
||||
FetchContent_Populate(fmt)
|
||||
# We do not require os features of fmt
|
||||
set(FMT_OS OFF CACHE BOOL "Disable FMT_OS" FORCE)
|
||||
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR})
|
||||
set_target_properties(fmt PROPERTIES FOLDER "third-party")
|
||||
endif ()
|
||||
set_target_properties(fmt PROPERTIES FOLDER "third-party")
|
||||
endif()
|
||||
|
@ -9,4 +9,4 @@ if(NOT TARGET spdlog)
|
||||
endif()
|
||||
|
||||
add_executable(example example.cpp)
|
||||
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
|
||||
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
|
||||
|
@ -161,7 +161,6 @@ void async_example() {
|
||||
// {:p} - don't print the position on each line start.
|
||||
// {:n} - don't split the output to lines.
|
||||
|
||||
|
||||
#include "spdlog/fmt/bin_to_hex.h"
|
||||
void binary_example() {
|
||||
std::vector<char> buf;
|
||||
@ -238,7 +237,6 @@ struct my_type {
|
||||
: i(i) {}
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<my_type> : fmt::formatter<std::string> {
|
||||
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <version>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(SPDLOG_SHARED_LIB)
|
||||
#if defined(_WIN32)
|
||||
#ifdef spdlog_EXPORTS
|
||||
@ -39,10 +38,10 @@
|
||||
#include "fmt/fmt.h"
|
||||
|
||||
#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
|
||||
#define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
|
||||
#if defined(SPDLOG_WCHAR_FILENAMES)
|
||||
#include "fmt/xchar.h"
|
||||
#endif
|
||||
#define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
|
||||
#if defined(SPDLOG_WCHAR_FILENAMES)
|
||||
#include "fmt/xchar.h"
|
||||
#endif
|
||||
|
||||
#ifndef SPDLOG_FUNCTION
|
||||
#define SPDLOG_FUNCTION static_cast<const char *>(__FUNCTION__)
|
||||
|
@ -47,13 +47,13 @@ inline unsigned int count_digits(T n) {
|
||||
using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type;
|
||||
|
||||
return static_cast<unsigned int>(fmt::
|
||||
// fmt 7.0.0 renamed the internal namespace to detail.
|
||||
// See: https://github.com/fmtlib/fmt/issues/1538
|
||||
#if FMT_VERSION < 70000
|
||||
// fmt 7.0.0 renamed the internal namespace to detail.
|
||||
// See: https://github.com/fmtlib/fmt/issues/1538
|
||||
#if FMT_VERSION < 70000
|
||||
internal
|
||||
#else
|
||||
#else
|
||||
detail
|
||||
#endif
|
||||
#endif
|
||||
::count_digits(static_cast<count_type>(n)));
|
||||
}
|
||||
|
||||
|
@ -203,4 +203,4 @@ struct formatter<spdlog::details::dump_info<T>, char> {
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
} // namespace fmt
|
||||
|
@ -51,8 +51,7 @@ public:
|
||||
} // namespace spdlog
|
||||
|
||||
// Support for fmt formatting (e.g. "{:012.9}" or just "{}")
|
||||
namespace fmt
|
||||
{
|
||||
namespace fmt {
|
||||
|
||||
template <>
|
||||
struct formatter<spdlog::stopwatch> : formatter<double> {
|
||||
@ -61,4 +60,4 @@ struct formatter<spdlog::stopwatch> : formatter<double> {
|
||||
return formatter<double>::format(sw.elapsed().count(), ctx);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
} // namespace fmt
|
||||
|
@ -19,12 +19,12 @@ if(Catch2_FOUND)
|
||||
else()
|
||||
message(STATUS "Bundled version of Catch will be downloaded and used.")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG 53d0d913a422d356b23dd927547febdf69ee9081 # v3.5.0
|
||||
FetchContent_Declare(
|
||||
Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG 53d0d913a422d356b23dd927547febdf69ee9081 # v3.5.0
|
||||
)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
set_target_properties(Catch2 Catch2WithMain PROPERTIES FOLDER "third-party")
|
||||
set_target_properties(Catch2 Catch2WithMain PROPERTIES FOLDER "third-party")
|
||||
endif()
|
||||
|
||||
set(SPDLOG_UTESTS_SOURCES
|
||||
@ -79,9 +79,9 @@ function(spdlog_prepare_test test_target spdlog_lib)
|
||||
target_link_libraries(${test_target} PRIVATE Catch2::Catch2WithMain)
|
||||
if(SPDLOG_SANITIZE_ADDRESS)
|
||||
spdlog_enable_addr_sanitizer(${test_target})
|
||||
elseif (SPDLOG_SANITIZE_THREAD)
|
||||
elseif(SPDLOG_SANITIZE_THREAD)
|
||||
spdlog_enable_thread_sanitizer(${test_target})
|
||||
endif ()
|
||||
endif()
|
||||
add_test(NAME ${test_target} COMMAND ${test_target})
|
||||
set_tests_properties(${test_target} PROPERTIES RUN_SERIAL ON)
|
||||
endfunction()
|
||||
|
@ -81,8 +81,7 @@ TEST_CASE("dir_name", "[create_dir]") {
|
||||
// clang-format off
|
||||
#include <windows.h>
|
||||
#include <fileapi.h>
|
||||
// clang-format on
|
||||
|
||||
// clang-format on
|
||||
|
||||
std::string get_full_path(const std::string &relative_folder_path) {
|
||||
char full_path[MAX_PATH];
|
||||
|
@ -18,7 +18,6 @@ protected:
|
||||
};
|
||||
struct custom_ex {};
|
||||
|
||||
|
||||
TEST_CASE("default_error_handler", "[errors]") {
|
||||
prepare_logdir();
|
||||
spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG);
|
||||
|
Loading…
Reference in New Issue
Block a user