clang-format

This commit is contained in:
gabime 2024-11-29 15:02:13 +02:00
parent ea896885cd
commit b0e836b000
13 changed files with 57 additions and 74 deletions

View File

@ -34,7 +34,6 @@ elseif(CMAKE_CXX_STANDARD LESS 17)
endif() endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR CMAKE_SYSTEM_NAME MATCHES "MINGW") 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 # build shared option
option(SPDLOG_BUILD_SHARED "Build shared library" OFF) option(SPDLOG_BUILD_SHARED "Build shared library" OFF)
# example options # example options
option(SPDLOG_BUILD_EXAMPLE "Build example" ${SPDLOG_MASTER_PROJECT}) 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_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) option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
# misc tweakme options # misc tweakme options
if(WIN32) if(WIN32)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF) option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
@ -129,7 +126,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/MP) add_compile_options(/MP)
endif() endif()
message(STATUS "spdlog version: ${SPDLOG_VERSION}") message(STATUS "spdlog version: ${SPDLOG_VERSION}")
message(STATUS "spdlog build type: " ${CMAKE_BUILD_TYPE}) message(STATUS "spdlog build type: " ${CMAKE_BUILD_TYPE})
message(STATUS "spdlog build shared: " ${BUILD_SHARED_LIBS}) message(STATUS "spdlog build shared: " ${BUILD_SHARED_LIBS})
@ -205,8 +201,7 @@ set(SPDLOG_HEADERS
"include/spdlog/sinks/syslog_sink.h" "include/spdlog/sinks/syslog_sink.h"
"include/spdlog/sinks/systemd_sink.h" "include/spdlog/sinks/systemd_sink.h"
"include/spdlog/sinks/tcp_sink.h" "include/spdlog/sinks/tcp_sink.h"
"include/spdlog/sinks/udp_sink.h" "include/spdlog/sinks/udp_sink.h")
)
set(SPDLOG_SRCS set(SPDLOG_SRCS
"src/async_logger.cpp" "src/async_logger.cpp"
@ -230,10 +225,10 @@ set(SPDLOG_SRCS
"src/sinks/stdout_sinks.cpp") "src/sinks/stdout_sinks.cpp")
if(WIN32) if(WIN32)
list(APPEND SPDLOG_SRCS list(APPEND SPDLOG_SRCS "src/details/os_windows.cpp" "src/sinks/wincolor_sink.cpp")
"src/details/os_windows.cpp" list(
"src/sinks/wincolor_sink.cpp") APPEND
list(APPEND SPDLOG_HEADERS SPDLOG_HEADERS
"include/spdlog/details/tcp_client_windows.h" "include/spdlog/details/tcp_client_windows.h"
"include/spdlog/details/udp_client_windows.h" "include/spdlog/details/udp_client_windows.h"
"include/spdlog/details/windows_include.h" "include/spdlog/details/windows_include.h"
@ -241,9 +236,7 @@ if(WIN32)
"include/spdlog/sinks/wincolor_sink.h") "include/spdlog/sinks/wincolor_sink.h")
else() else()
list(APPEND SPDLOG_SRCS "src/details/os_unix.cpp") list(APPEND SPDLOG_SRCS "src/details/os_unix.cpp")
list(APPEND SPDLOG_HEADERS list(APPEND SPDLOG_HEADERS "include/spdlog/details/tcp_client_unix.h" "include/spdlog/details/udp_client_unix.h")
"include/spdlog/details/tcp_client_unix.h"
"include/spdlog/details/udp_client_unix.h")
endif() endif()
# Generate spdlog_config.h based on the current configuration # Generate spdlog_config.h based on the current configuration
@ -275,14 +268,14 @@ endif()
set_target_properties(spdlog PROPERTIES PUBLIC_HEADER "${SPDLOG_HEADERS}") set_target_properties(spdlog PROPERTIES PUBLIC_HEADER "${SPDLOG_HEADERS}")
target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(spdlog PUBLIC Threads::Threads) target_link_libraries(spdlog PUBLIC Threads::Threads)
target_link_libraries(spdlog PUBLIC fmt::fmt) target_link_libraries(spdlog PUBLIC fmt::fmt)
spdlog_enable_warnings(spdlog) 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_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)
# set source groups for visual studio # set source groups for visual studio
@ -299,7 +292,6 @@ if(ANDROID)
target_link_libraries(spdlog PUBLIC log) target_link_libraries(spdlog PUBLIC log)
endif() endif()
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
# If exceptions are disabled, disable them in the bundled fmt as well # If exceptions are disabled, disable them in the bundled fmt as well
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
@ -389,8 +381,7 @@ if(SPDLOG_INSTALL)
# --------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------
include(cmake/spdlogCPack.cmake) include(cmake/spdlogCPack.cmake)
# Install spdlog_config.h file # Install spdlog_config.h file Assume your tweakme.h.in is located in the same directory as CMakeLists.txt
# 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_IN "${CMAKE_CURRENT_SOURCE_DIR}/tweakme.h.in")
set(TWEAKME_OUT "${CMAKE_CURRENT_BINARY_DIR}/include/spdlog/tweakme.h") set(TWEAKME_OUT "${CMAKE_CURRENT_BINARY_DIR}/include/spdlog/tweakme.h")
endif() endif()

View File

@ -6,19 +6,19 @@
// //
// bench.cpp : spdlog benchmarks // 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 <fmt/format.h>
#include <atomic> #include <atomic>
#include <cstdlib> // EXIT_FAILURE #include <cstdlib> // EXIT_FAILURE
#include <memory> #include <memory>
#include <string> #include <string>
#include <thread> #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" #include "utils.h"
void bench(int howmany, std::shared_ptr<spdlog::logger> log); void bench(int howmany, std::shared_ptr<spdlog::logger> log);

View File

@ -1,9 +1,7 @@
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
fmt fmt DOWNLOAD_EXTRACT_TIMESTAMP FALSE URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz
URL_HASH SHA256=6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f) URL_HASH SHA256=6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f)
FetchContent_GetProperties(fmt) FetchContent_GetProperties(fmt)
if(NOT fmt_POPULATED) if(NOT fmt_POPULATED)

View File

@ -161,7 +161,6 @@ void async_example() {
// {:p} - don't print the position on each line start. // {:p} - don't print the position on each line start.
// {:n} - don't split the output to lines. // {:n} - don't split the output to lines.
#include "spdlog/fmt/bin_to_hex.h" #include "spdlog/fmt/bin_to_hex.h"
void binary_example() { void binary_example() {
std::vector<char> buf; std::vector<char> buf;
@ -238,7 +237,6 @@ struct my_type {
: i(i) {} : i(i) {}
}; };
template <> template <>
struct fmt::formatter<my_type> : fmt::formatter<std::string> { struct fmt::formatter<my_type> : fmt::formatter<std::string> {
auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) { auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) {

View File

@ -21,7 +21,6 @@
#include <version> #include <version>
#endif #endif
#if defined(SPDLOG_SHARED_LIB) #if defined(SPDLOG_SHARED_LIB)
#if defined(_WIN32) #if defined(_WIN32)
#ifdef spdlog_EXPORTS #ifdef spdlog_EXPORTS

View File

@ -203,4 +203,4 @@ struct formatter<spdlog::details::dump_info<T>, char> {
} }
} }
}; };
} // namespace std } // namespace fmt

View File

@ -51,8 +51,7 @@ public:
} // namespace spdlog } // namespace spdlog
// Support for fmt formatting (e.g. "{:012.9}" or just "{}") // Support for fmt formatting (e.g. "{:012.9}" or just "{}")
namespace fmt namespace fmt {
{
template <> template <>
struct formatter<spdlog::stopwatch> : formatter<double> { struct formatter<spdlog::stopwatch> : formatter<double> {
@ -61,4 +60,4 @@ struct formatter<spdlog::stopwatch> : formatter<double> {
return formatter<double>::format(sw.elapsed().count(), ctx); return formatter<double>::format(sw.elapsed().count(), ctx);
} }
}; };
} // namespace std } // namespace fmt

View File

@ -19,8 +19,8 @@ if(Catch2_FOUND)
else() else()
message(STATUS "Bundled version of Catch will be downloaded and used.") message(STATUS "Bundled version of Catch will be downloaded and used.")
include(FetchContent) include(FetchContent)
FetchContent_Declare(Catch2 FetchContent_Declare(
GIT_REPOSITORY https://github.com/catchorg/Catch2.git Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG 53d0d913a422d356b23dd927547febdf69ee9081 # v3.5.0 GIT_TAG 53d0d913a422d356b23dd927547febdf69ee9081 # v3.5.0
) )
FetchContent_MakeAvailable(Catch2) FetchContent_MakeAvailable(Catch2)

View File

@ -83,7 +83,6 @@ TEST_CASE("dir_name", "[create_dir]") {
#include <fileapi.h> #include <fileapi.h>
// clang-format on // clang-format on
std::string get_full_path(const std::string &relative_folder_path) { std::string get_full_path(const std::string &relative_folder_path) {
char full_path[MAX_PATH]; char full_path[MAX_PATH];

View File

@ -18,7 +18,6 @@ protected:
}; };
struct custom_ex {}; struct custom_ex {};
TEST_CASE("default_error_handler", "[errors]") { TEST_CASE("default_error_handler", "[errors]") {
prepare_logdir(); prepare_logdir();
spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG); spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG);