2019-07-01 02:06:09 +03:00
|
|
|
project(spdlog_utests CXX)
|
|
|
|
|
2019-07-01 15:03:53 +03:00
|
|
|
include(../cmake/utils.cmake)
|
|
|
|
|
2019-06-28 17:29:52 +03:00
|
|
|
find_package(PkgConfig)
|
|
|
|
if(PkgConfig_FOUND)
|
|
|
|
pkg_check_modules(systemd libsystemd)
|
|
|
|
endif()
|
|
|
|
|
2018-02-11 20:45:56 +01:00
|
|
|
set(SPDLOG_UTESTS_SOURCES
|
2018-11-22 12:31:16 +02:00
|
|
|
test_file_helper.cpp
|
2018-11-20 12:14:21 +02:00
|
|
|
test_file_logging.cpp
|
2019-09-15 18:34:29 +03:00
|
|
|
test_daily_logger.cpp
|
2018-02-23 16:49:26 +02:00
|
|
|
test_misc.cpp
|
2018-08-14 21:33:47 +02:00
|
|
|
test_pattern_formatter.cpp
|
2018-05-22 21:59:27 +03:00
|
|
|
test_async.cpp
|
2018-10-13 19:23:11 +03:00
|
|
|
test_registry.cpp
|
2018-02-11 20:45:56 +01:00
|
|
|
test_macros.cpp
|
|
|
|
utils.cpp
|
2018-08-14 21:33:47 +02:00
|
|
|
main.cpp
|
|
|
|
test_mpmc_q.cpp
|
2019-11-04 17:43:30 +02:00
|
|
|
test_dup_filter.cpp
|
2019-06-20 01:02:54 +03:00
|
|
|
test_fmt_helper.cpp
|
2019-06-28 08:07:15 +03:00
|
|
|
test_stdout_api.cpp
|
2019-10-20 17:40:56 +03:00
|
|
|
test_backtrace.cpp
|
|
|
|
test_create_dir.cpp)
|
2018-02-11 20:45:56 +01:00
|
|
|
|
2019-08-19 11:31:33 +03:00
|
|
|
if(NOT SPDLOG_NO_EXCEPTIONS)
|
|
|
|
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
|
|
|
endif()
|
|
|
|
|
2019-06-28 17:29:52 +03:00
|
|
|
if(systemd_FOUND)
|
2019-07-07 14:09:23 +03:00
|
|
|
list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
|
2019-06-28 17:29:52 +03:00
|
|
|
endif()
|
|
|
|
|
2019-11-04 17:19:18 +02:00
|
|
|
|
2018-08-14 21:33:47 +02:00
|
|
|
enable_testing()
|
2019-05-29 00:04:36 +03:00
|
|
|
|
2019-10-25 10:19:15 +03:00
|
|
|
function(spdlog_prepare_test test_target spdlog_lib)
|
2019-10-24 22:57:47 +03:00
|
|
|
add_executable(${test_target} ${SPDLOG_UTESTS_SOURCES})
|
|
|
|
spdlog_enable_warnings(${test_target})
|
|
|
|
target_link_libraries(${test_target} PRIVATE ${spdlog_lib})
|
2019-06-28 17:29:52 +03:00
|
|
|
if(systemd_FOUND)
|
2019-10-24 22:57:47 +03:00
|
|
|
target_link_libraries(${test_target} PRIVATE ${systemd_LIBRARIES})
|
2019-06-28 17:29:52 +03:00
|
|
|
endif()
|
2019-06-10 18:09:36 +03:00
|
|
|
if(SPDLOG_SANITIZE_ADDRESS)
|
2019-10-24 22:57:47 +03:00
|
|
|
spdlog_enable_sanitizer(${test_target})
|
2019-06-10 18:09:36 +03:00
|
|
|
endif()
|
2019-10-28 02:52:59 -05:00
|
|
|
add_test(NAME ${test_target} COMMAND ${test_target})
|
2019-10-25 10:19:15 +03:00
|
|
|
endfunction()
|
2019-10-24 22:57:47 +03:00
|
|
|
|
|
|
|
# The compiled library tests
|
|
|
|
if(SPDLOG_BUILD_TESTS)
|
2019-10-25 10:19:15 +03:00
|
|
|
spdlog_prepare_test(spdlog-utests spdlog::spdlog)
|
2019-05-29 00:04:36 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# The header-only library version tests
|
2019-07-01 02:06:09 +03:00
|
|
|
if(SPDLOG_BUILD_TESTS_HO)
|
2019-10-25 10:19:15 +03:00
|
|
|
spdlog_prepare_test(spdlog-utests-ho spdlog::spdlog_header_only)
|
2019-06-10 18:32:10 +03:00
|
|
|
endif()
|