add loggers

This commit is contained in:
2026-07-06 18:59:09 +03:00
parent dc8e209953
commit b04bfab964
5 changed files with 280 additions and 1 deletions

View File

@@ -3,12 +3,42 @@ project(snipplib VERSION 0.1.0 LANGUAGES CXX)
option(SNPLIB_BUILD_EXAMPLES "Build examples" ON)
option(SNPLIB_USE_SPDLOG "Use of spdlog library" ON)
if(SNPLIB_USE_SPDLOG)
find_package(spdlog CONFIG)
if(NOT spdlog_FOUND)
FetchContent_Declare(
spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
GIT_TAG "v1.17.0"
GIT_SHALLOW TRUE
GIT_SUBMODULES ""
GIT_PROGRESS TRUE
# CMAKE_ARGS
# -DSPDLOG_USE_STD_FORMAT=ON
# -DSPDLOG_FMT_EXTERNAL=OFF
OVERRIDE_FIND_PACKAGE
)
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
set(SPDLOG_FMT_EXTERNAL
OFF
CACHE INTERNAL
"Turn off external fmt library"
)
set(SPDLOG_INSTALL ON CACHE BOOL "Enable spdlog installation" FORCE)
FetchContent_MakeAvailable(spdlog)
endif()
endif(SNPLIB_USE_SPDLOG)
set(LIB_HEADERS
include/snipplib/concepts/snplib_concepts.h
include/snipplib/concepts/snplib_traits.h
include/snipplib/utils/snplib_hash.h
include/snipplib/utils/snplib_string.h
include/snipplib/utils/snplib_keyvalue_expr.h
include/snipplib/utils/snplib_logger.h
include/snipplib/utils/snplib_utils.h
include/snipplib/containers/snplib_hmap.h
include/snipplib/containers/snplib_hvec.h
@@ -24,6 +54,16 @@ target_include_directories(
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
if(SNPLIB_USE_SPDLOG)
target_compile_definitions(
${PROJECT_NAME}
INTERFACE
SPDLOG_USE_STD_FORMAT=1
SPDLOG_FMT_EXTERNAL=0
SNPLIB_SPDLOGGER=1
)
target_link_libraries(${PROJECT_NAME} INTERFACE spdlog::spdlog_header_only)
endif()
if(SNPLIB_BUILD_EXAMPLES)
set(EXAM_STRING str_exam)