diff --git a/.clang-format b/.clang-format new file mode 120000 index 00000000..bd874d3d --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +scripts/.clang-format \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy new file mode 120000 index 00000000..5022e7a6 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1 @@ +scripts/.clang-tidy \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1b452285..81add465 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # Auto generated files build/* +/build-*/ +/testreports/ +/logs/ *.slo *.lo *.o diff --git a/CMakeLists.txt b/CMakeLists.txt index 508a0b65..30c569ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright(c) 2019 spdlog authors # Distributed under the MIT License (http://opensource.org/licenses/MIT) -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.13) #--------------------------------------------------------------------------------------- # Start spdlog project @@ -9,6 +9,7 @@ cmake_minimum_required(VERSION 3.2) include(GNUInstallDirs) include(cmake/utils.cmake) include(cmake/ide.cmake) +include(cmake/clang-tidy.cmake) spdlog_extract_version() @@ -22,18 +23,19 @@ endif() project(spdlog VERSION ${SPDLOG_VERSION} LANGUAGES CXX) message(STATUS "Build spdlog: ${SPDLOG_VERSION}") + #--------------------------------------------------------------------------------------- # Compiler config #--------------------------------------------------------------------------------------- -if (NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() - -set(CMAKE_CXX_EXTENSIONS OFF) -if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") - set(CMAKE_CXX_EXTENSIONS ON) + if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") + set(CMAKE_CXX_EXTENSIONS ON) + else() + set(CMAKE_CXX_EXTENSIONS OFF) + endif() endif() @@ -41,13 +43,13 @@ endif() # Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog #--------------------------------------------------------------------------------------- # Check if spdlog is being used directly or via add_subdirectory, but allow overriding -if (NOT DEFINED SPDLOG_MASTER_PROJECT) - if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) +if(NOT DEFINED SPDLOG_MASTER_PROJECT) + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(SPDLOG_MASTER_PROJECT ON) else() set(SPDLOG_MASTER_PROJECT OFF) endif() -endif () +endif() # build shared option if(NOT WIN32) @@ -60,7 +62,7 @@ option(SPDLOG_BUILD_EXAMPLE_HO "Build header only example" OFF) # testing options option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT}) -option(SPDLOG_BUILD_TESTS_HO "Build tests using the header only version" OFF) +option(SPDLOG_BUILD_TESTS_HO "Build tests using the header only version" ${SPDLOG_MASTER_PROJECT}) # bench options option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF) @@ -74,7 +76,7 @@ option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF) option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of bundled" OFF) option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF) -if (SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO) +if(SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO) message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive") endif() @@ -93,7 +95,9 @@ 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) find_package(Threads REQUIRED) -message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) +message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") + + #--------------------------------------------------------------------------------------- # Static/Shared library (shared not supported in windows yet) #--------------------------------------------------------------------------------------- @@ -109,7 +113,7 @@ if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO) list(APPEND SPDLOG_SRCS src/fmt.cpp) endif() -if (SPDLOG_BUILD_SHARED) +if(SPDLOG_BUILD_SHARED) if(WIN32) message(FATAL_ERROR "spdlog shared lib is not yet supported under windows") endif() @@ -122,7 +126,7 @@ add_library(spdlog::spdlog ALIAS spdlog) target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB) target_include_directories(spdlog PUBLIC - "$" + "$" "$") target_link_libraries(spdlog PUBLIC Threads::Threads) spdlog_enable_warnings(spdlog) @@ -130,6 +134,7 @@ spdlog_enable_warnings(spdlog) set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}) set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d) + #--------------------------------------------------------------------------------------- # Header only version #--------------------------------------------------------------------------------------- @@ -137,7 +142,7 @@ add_library(spdlog_header_only INTERFACE) add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only) target_include_directories(spdlog_header_only INTERFACE - "$" + "$" "$") target_link_libraries(spdlog_header_only INTERFACE Threads::Threads) @@ -146,9 +151,9 @@ target_link_libraries(spdlog_header_only INTERFACE Threads::Threads) # Use fmt package if using external fmt #--------------------------------------------------------------------------------------- if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO) - if (NOT TARGET fmt::fmt) + if(NOT TARGET fmt::fmt) find_package(fmt REQUIRED) - endif () + endif() target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL) target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL) @@ -164,23 +169,23 @@ if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO) set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config 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) - endif() - - if(SPDLOG_WCHAR_FILENAMES) - target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_FILENAMES) - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES) - endif() + 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_NO_EXCEPTIONS) - target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS) +if(SPDLOG_WCHAR_FILENAMES) + target_compile_definitions(spdlog PUBLIC SPDLOG_WCHAR_FILENAMES) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES) +endif() - target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_EXCEPTIONS) +if(SPDLOG_NO_EXCEPTIONS) + target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_NO_EXCEPTIONS) if(NOT MSVC) target_compile_options(spdlog PRIVATE -fno-exceptions) @@ -232,12 +237,13 @@ if(SPDLOG_BUILD_BENCH) add_subdirectory(bench) endif() + #--------------------------------------------------------------------------------------- # Install #--------------------------------------------------------------------------------------- -if (SPDLOG_INSTALL) +if(SPDLOG_INSTALL) message(STATUS "Generating install") - set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/spdlogConfig.cmake.in") + set(project_config_in "${CMAKE_CURRENT_SOURCE_DIR}/cmake/spdlogConfig.cmake.in") set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake") set(config_targets_file "spdlogConfigTargets.cmake") set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfigVersion.cmake") @@ -274,8 +280,9 @@ if (SPDLOG_INSTALL) FILE ${config_targets_file}) include(CMakePackageConfigHelpers) - configure_file("${project_config_in}" "${project_config_out}" @ONLY) - + configure_package_config_file("${project_config_in}" "${project_config_out}" + INSTALL_DESTINATION ${export_dest_dir} + ) write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion) install(FILES "${project_config_out}" @@ -286,5 +293,5 @@ if (SPDLOG_INSTALL) #--------------------------------------------------------------------------------------- include(cmake/spdlogCPack.cmake) -endif () +endif() diff --git a/build_performance_measure.py b/build_performance_measure.py new file mode 100755 index 00000000..7e2fb33d --- /dev/null +++ b/build_performance_measure.py @@ -0,0 +1,151 @@ +#!/usr/bin/python3 -tt + +""" +Claus-MBP:spdlog clausklein$ python build_performance_measure.py +Running command: rm -rf build-cmake-ninja && mkdir -p build-cmake-ninja && CXX='ccache clang++' cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLE_HO=ON -G Ninja -B build-cmake-ninja . +Running command: ninja -j 2 -C build-cmake-ninja +Running command: ninja -j 2 -C build-cmake-ninja +Running command: ninja -j 2 -C build-cmake-ninja clean +Running command: ninja -j 2 -C build-cmake-ninja +Running command: rm -rf build-meson && mkdir -p build-meson && CXX='ccache clang++' meson build-meson +Running command: ninja -j 2 -C build-meson +Running command: ninja -j 2 -C build-meson +Running command: ninja -j 2 -C build-meson clean +Running command: ninja -j 2 -C build-meson +cmake-ninja + 2.954 gen + 1.427 build + 0.017 empty build + 0.043 clean + 1.245 rebuild + 5.686 overall +meson + 4.642 gen + 1.246 build + 0.016 empty build + 0.037 clean + 1.159 rebuild + 7.100 overall +Claus-MBP:spdlog clausklein$ cd build-cmake-ninja/ +Claus-MBP:build-cmake-ninja clausklein$ !find +find . -type f -name '*.o' -o -name '*.a' +./CMakeFiles/spdlog.dir/src/async.cpp.o +./CMakeFiles/spdlog.dir/src/color_sinks.cpp.o +./CMakeFiles/spdlog.dir/src/file_sinks.cpp.o +./CMakeFiles/spdlog.dir/src/fmt.cpp.o +./CMakeFiles/spdlog.dir/src/spdlog.cpp.o +./CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o +./example/CMakeFiles/example.dir/example.cpp.o +./example/CMakeFiles/example_header_only.dir/example.cpp.o +./libspdlog.a +./tests/CMakeFiles/spdlog-utests.dir/main.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_async.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_backtrace.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_create_dir.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_daily_logger.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_dup_filter.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_errors.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_file_helper.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_file_logging.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_fmt_helper.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_macros.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_misc.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_mpmc_q.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_pattern_formatter.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_registry.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/test_stdout_api.cpp.o +./tests/CMakeFiles/spdlog-utests.dir/utils.cpp.o +Claus-MBP:build-cmake-ninja clausklein$ find . -type f -name '*.o' -o -name '*.a' | wc + 26 26 1345 +Claus-MBP:build-cmake-ninja clausklein$ cd ../build-meson/ +Claus-MBP:build-meson clausklein$ find . -type f -name '*.o' -o -name '*.a' | wc + 26 26 1241 +Claus-MBP:build-meson clausklein$ find . -type f -name '*.o' -o -name '*.a' +./example/50d858e@@example@exe/example.cpp.o +./example/50d858e@@example_header_only@exe/example.cpp.o +./libspdlog.a +./spdlog@sta/src_async.cpp.o +./spdlog@sta/src_color_sinks.cpp.o +./spdlog@sta/src_file_sinks.cpp.o +./spdlog@sta/src_fmt.cpp.o +./spdlog@sta/src_spdlog.cpp.o +./spdlog@sta/src_stdout_sinks.cpp.o +./tests/59830eb@@spdlog-utests@exe/main.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_async.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_backtrace.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_create_dir.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_daily_logger.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_dup_filter.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_errors.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_file_helper.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_file_logging.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_fmt_helper.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_macros.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_misc.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_mpmc_q.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_pattern_formatter.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_registry.cpp.o +./tests/59830eb@@spdlog-utests@exe/test_stdout_api.cpp.o +./tests/59830eb@@spdlog-utests@exe/utils.cpp.o +Claus-MBP:build-meson clausklein$ +""" + +import sys +import os +import time +import subprocess + + +def gettime(command): + if command is None: + return 0.0 + print('Running command:', command) + starttime = time.time() + subprocess.check_call(command, shell=True, stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + endtime = time.time() + return endtime - starttime + + +def measure(): + measurements = [ + #NO! ['cmake-make', 'rm -rf build-cmake && mkdir -p build-cmake && CXX=g++ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -B build-cmake .', + # 'make -C build-cmake -j 4', 'make -C build-cmake -j 4 clean'], + ['cmake-ninja', 'rm -rf build-cmake-ninja && mkdir -p build-cmake-ninja && CXX=\'ccache clang++\' cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLE_HO=ON -G Ninja -B build-cmake-ninja .', + 'ninja -j 2 -C build-cmake-ninja', 'ninja -j 2 -C build-cmake-ninja clean'], + ['meson', 'rm -rf build-meson && mkdir -p build-meson && CXX=\'ccache clang++\' meson build-meson', + 'ninja -j 2 -C build-meson', 'ninja -j 2 -C build-meson clean'], + ] + results = [] + for m in measurements: + cur = [] + results.append(cur) + cur.append(m[0]) + conf = m[1] + make = m[2] + clean = m[3] + cur.append(gettime(conf)) + cur.append(gettime(make)) + cur.append(gettime(make)) + cur.append(gettime(clean)) + cur.append(gettime(make)) + return results + + +def print_times(times): + for t in times: + print(t[0]) + print(" %.3f gen" % t[1]) + print(" %.3f build" % t[2]) + print(" %.3f empty build" % t[3]) + print(" %.3f clean" % t[4]) + print(" %.3f rebuild" % t[5]) + overall = t[1] + t[2] + t[3] + t[4] + t[5] + print(" %.3f overall" % overall) + + +if __name__ == '__main__': + # if len(sys.argv) != 2: + # print(sys.argv[0], '') + # os.chdir(sys.argv[1]) + print_times(measure()) diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake new file mode 100644 index 00000000..1b5a5bd7 --- /dev/null +++ b/cmake/clang-tidy.cmake @@ -0,0 +1,34 @@ +option(ENABLE_CLANG_TIDY "Add run-clang-tidy automatically to builds" OFF) +find_program(CLANG_TIDY_EXE + NAMES run-clang-tidy.py run-clang-tidy run-clang-tidy-7 + DOC "Path to clang-tidy executable") +if(CLANG_TIDY_EXE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(DCMAKE_EXPORT_COMPILE_COMMANDS ON) + set(CLANG_TIDY_CHECKS "'-*,cppcoreguidelines-*,-cppcoreguidelines-macro-usage'") + set(CLANG_TIDY_CMD "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'") + message(STATUS "cmake source dir: ${CMAKE_SOURCE_DIR}") + + if(ENABLE_CLANG_TIDY) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_CMD} CACHE STRING "" FORCE) + else() + set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it + endif() + + if(NOT TARGET check) + add_custom_target(check) + message(STATUS "check target added") + set_target_properties(check PROPERTIES EXCLUDE_FROM_ALL TRUE) + endif() + + add_custom_command(TARGET check PRE_BUILD + # -p BUILD_PATH Path used to read a compile command database (compile_commands.json). + # NOTE: we use defaults checks from .clang-tidy + COMMAND ${CLANG_TIDY_EXE} -p ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" # location of compile_commands.json + COMMENT "Running check on targets at ${CMAKE_SOURCE_DIR} ..." + VERBATIM + ) +else() + message(AUTHOR_WARNING "run-clang-tidy not found!") +endif() diff --git a/cmake/ide.cmake b/cmake/ide.cmake index 27472c38..b2080cd6 100644 --- a/cmake/ide.cmake +++ b/cmake/ide.cmake @@ -14,5 +14,5 @@ source_group("Header Files\\spdlog" FILES ${SPDLOG_TOP_HEADERS}) source_group("Header Files\\spdlog\\details" FILES ${SPDLOG_DETAILS_HEADERS}) source_group("Header Files\\spdlog\\sinks" FILES ${SPDLOG_SINKS_HEADERS}) source_group("Header Files\\spdlog\\fmt" FILES ${SPDLOG_FMT_HEADERS}) -source_group("Header Files\\spdlog\\fmt\\bundled\\" FILES ${SPDLOG_FMT_BUNDELED_HEADERS}) +source_group("Header Files\\spdlog\\fmt\\bundled" FILES ${SPDLOG_FMT_BUNDELED_HEADERS}) diff --git a/cmake/spdlogCPack.cmake b/cmake/spdlogCPack.cmake index 6ee2e51c..88ac1d8d 100644 --- a/cmake/spdlogCPack.cmake +++ b/cmake/spdlogCPack.cmake @@ -19,9 +19,9 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) -if (PROJECT_VERSION_TWEAK) +if(PROJECT_VERSION_TWEAK) set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}.${PROJECT_VERSION_TWEAK}) -endif () +endif() set(CPACK_PACKAGE_RELOCATABLE ON) set(CPACK_RPM_PACKAGE_LICENSE "MIT") diff --git a/cmake/utils.cmake b/cmake/utils.cmake index cfa1f458..b9d19c1c 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,26 +1,26 @@ # 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 "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE) + set(SPDLOG_VERSION "${ver_major}.${ver_minor}.${ver_patch}" PARENT_SCOPE) endfunction() @@ -30,21 +30,21 @@ function(spdlog_enable_warnings target_name) $<$,$,$>: -Wall -Wextra -Wconversion -pedantic -Wfatal-errors> $<$:/W4>) - if(MSVC_VERSION GREATER 1900) #Allow non fatal security wanrnings for msvc 2015 - target_compile_options(${target_name} PRIVATE /WX) - endif() + if(MSVC_VERSION GREATER 1900) #Allow non fatal security wanrnings for msvc 2015 + target_compile_options(${target_name} PRIVATE /WX) + endif() 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/meson_options.txt b/meson_options.txt index 711c7dd6..18c3e650 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,7 +2,7 @@ option('external_fmt', type: 'boolean', value: false, description: 'Use ex option('enable_examples', type: 'boolean', value: true, description: 'Build examples') option('enable_benchmarks', type: 'boolean', value: false, description: 'Build benchmarks') option('enable_tests', type: 'boolean', value: true, description: 'Build tests') -option('enable_tests_ho', type: 'boolean', value: false, description: 'Build header-only tests') +option('enable_tests_ho', type: 'boolean', value: true, description: 'Build header-only tests') option('library_type', type: 'combo', choices: ['static', 'shared'], value: 'static', description: 'Library build type') option('no_exceptions', type: 'boolean', value: false, description: 'Disabled exceptions - abort() instead any error')