diff --git a/CMakeLists.txt b/CMakeLists.txt index ff7a64d3..0693c508 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(CMAKE_CXX_EXTENSIONS OFF) if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") - set(CMAKE_CXX_EXTENSIONS ON) + set(CMAKE_CXX_EXTENSIONS ON) endif() @@ -109,7 +109,7 @@ option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF) option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" OFF) # clang-tidy -if(${CMAKE_VERSION} VERSION_GREATER "3.5") +if(${CMAKE_VERSION} VERSION_GREATER "3.5") option(SPDLOG_TIDY "run clang-tidy" OFF) endif() @@ -127,7 +127,7 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) set(SPDLOG_SRCS src/spdlog.cpp src/stdout_sinks.cpp - src/color_sinks.cpp + src/color_sinks.cpp src/file_sinks.cpp src/async.cpp src/cfg.cpp) @@ -145,7 +145,7 @@ if (SPDLOG_BUILD_SHARED) target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB) if(WIN32) target_compile_options(spdlog PUBLIC /wd4251 /wd4275) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY) endif() if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO) target_compile_definitions(spdlog PRIVATE FMT_EXPORT PUBLIC FMT_SHARED) @@ -209,19 +209,19 @@ endif() # Misc definitions according to tweak options #--------------------------------------------------------------------------------------- if(SPDLOG_WCHAR_SUPPORT) - target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_TO_UTF8_SUPPORT) - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_TO_UTF8_SUPPORT) + target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_TO_UTF8_SUPPORT) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_TO_UTF8_SUPPORT) endif() if(SPDLOG_WCHAR_FILENAMES) - target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_FILENAMES) - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES) + target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_FILENAMES) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES) endif() if(SPDLOG_NO_EXCEPTIONS) - target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS) + target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS) - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_EXCEPTIONS) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_EXCEPTIONS) if(NOT MSVC) target_compile_options(spdlog PRIVATE -fno-exceptions) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 129df983..30d678da 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,28 +1,28 @@ # Get spdlog version from include/spdlog/version.h and put it in SPDLOG_VERSION function(spdlog_extract_version) - file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents) - string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}") - if(NOT CMAKE_MATCH_COUNT EQUAL 1) + file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents) + string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}") + if(NOT CMAKE_MATCH_COUNT EQUAL 1) message(FATAL_ERROR "Could not extract major version number from spdlog/version.h") - endif() - set(ver_major ${CMAKE_MATCH_1}) + endif() + set(ver_major ${CMAKE_MATCH_1}) - string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}") - if(NOT CMAKE_MATCH_COUNT EQUAL 1) + string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}") + if(NOT CMAKE_MATCH_COUNT EQUAL 1) message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h") - endif() + endif() - set(ver_minor ${CMAKE_MATCH_1}) - string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}") - if(NOT CMAKE_MATCH_COUNT EQUAL 1) + set(ver_minor ${CMAKE_MATCH_1}) + string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}") + if(NOT CMAKE_MATCH_COUNT EQUAL 1) message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h") - endif() - set(ver_patch ${CMAKE_MATCH_1}) + endif() + set(ver_patch ${CMAKE_MATCH_1}) set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE) - set(SPDLOG_VERSION_MINOR ${ver_minor} PARENT_SCOPE) - set(SPDLOG_VERSION_PATCH ${ver_patch} PARENT_SCOPE) - set (SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE) + set(SPDLOG_VERSION_MINOR ${ver_minor} PARENT_SCOPE) + set(SPDLOG_VERSION_PATCH ${ver_patch} PARENT_SCOPE) + set (SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE) endfunction() @@ -47,13 +47,13 @@ endfunction() # Enable address sanitizer (gcc/clang only) function(spdlog_enable_sanitizer target_name) - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - message(FATAL_ERROR "Sanitizer supported only for gcc/clang") - endif() - message(STATUS "Address sanitizer enabled") - target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined) - target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow) - target_compile_options(${target_name} PRIVATE -fno-sanitize-recover=all) - target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer) - target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined -fuse-ld=gold) + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + message(FATAL_ERROR "Sanitizer supported only for gcc/clang") + endif() + message(STATUS "Address sanitizer enabled") + target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined) + target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow) + target_compile_options(${target_name} PRIVATE -fno-sanitize-recover=all) + target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer) + target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined -fuse-ld=gold) endfunction() diff --git a/cmake/version.rc.in b/cmake/version.rc.in index f32808d5..ef537189 100644 --- a/cmake/version.rc.in +++ b/cmake/version.rc.in @@ -21,7 +21,7 @@ BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" - BEGIN + BEGIN VALUE "FileDescription", "spdlog dll\0" VALUE "FileVersion", "@SPDLOG_VERSION@.0\0" VALUE "InternalName", "spdlog.dll\0" diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index bb5be0bb..36b2ad33 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(example PRIVATE spdlog::spdlog) # Example of using header-only library #--------------------------------------------------------------------------------------- if(SPDLOG_BUILD_EXAMPLE_HO) - add_executable(example_header_only example.cpp) + add_executable(example_header_only example.cpp) target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index df6604f5..0ca05f81 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,13 +11,13 @@ include(../cmake/utils.cmake) find_package(PkgConfig) if(PkgConfig_FOUND) - pkg_check_modules(systemd libsystemd) + pkg_check_modules(systemd libsystemd) endif() set(SPDLOG_UTESTS_SOURCES test_file_helper.cpp test_file_logging.cpp - test_daily_logger.cpp + test_daily_logger.cpp test_misc.cpp test_eventlog.cpp test_pattern_formatter.cpp @@ -27,20 +27,20 @@ set(SPDLOG_UTESTS_SOURCES utils.cpp main.cpp test_mpmc_q.cpp - test_dup_filter.cpp + test_dup_filter.cpp test_fmt_helper.cpp - test_stdout_api.cpp - test_backtrace.cpp - test_create_dir.cpp - test_cfg.cpp - test_time_point.cpp) + test_stdout_api.cpp + test_backtrace.cpp + test_create_dir.cpp + test_cfg.cpp + test_time_point.cpp) if(NOT SPDLOG_NO_EXCEPTIONS) - list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp) + list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp) endif() if(systemd_FOUND) - list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp) + list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp) endif() @@ -48,14 +48,14 @@ enable_testing() function(spdlog_prepare_test test_target spdlog_lib) add_executable(${test_target} ${SPDLOG_UTESTS_SOURCES}) - spdlog_enable_warnings(${test_target}) + spdlog_enable_warnings(${test_target}) target_link_libraries(${test_target} PRIVATE ${spdlog_lib}) - if(systemd_FOUND) - target_link_libraries(${test_target} PRIVATE ${systemd_LIBRARIES}) - endif() - if(SPDLOG_SANITIZE_ADDRESS) - spdlog_enable_sanitizer(${test_target}) - endif() + if(systemd_FOUND) + target_link_libraries(${test_target} PRIVATE ${systemd_LIBRARIES}) + endif() + if(SPDLOG_SANITIZE_ADDRESS) + spdlog_enable_sanitizer(${test_target}) + endif() add_test(NAME ${test_target} COMMAND ${test_target}) set_tests_properties(${test_target} PROPERTIES RUN_SERIAL ON) endfunction()