CMakeLists.txt 1.7 KB
Newer Older
1 2
project(spdlog_utests CXX)

Gabi Melman's avatar
Gabi Melman committed
3 4
include(../cmake/utils.cmake)

5 6 7 8 9
find_package(PkgConfig)
if(PkgConfig_FOUND)
	pkg_check_modules(systemd libsystemd)
endif()

10
set(SPDLOG_UTESTS_SOURCES
gabime's avatar
gabime committed
11
    test_file_helper.cpp
gabime's avatar
gabime committed
12
    test_file_logging.cpp
13
	test_daily_logger.cpp
gabime's avatar
gabime committed
14
    test_misc.cpp
15
    test_pattern_formatter.cpp
gabime's avatar
gabime committed
16
    test_async.cpp
17
    includes.h
18
    test_registry.cpp
19 20 21
    test_macros.cpp
    utils.cpp
    utils.h
22 23 24
    main.cpp
    test_mpmc_q.cpp
    test_sink.h
gabime's avatar
gabime committed
25
    test_fmt_helper.cpp
26
  	test_stdout_api.cpp
gabime's avatar
gabime committed
27 28
    test_dup_filter.cpp
	test_backtrace.cpp)
29

30 31 32 33
if(NOT SPDLOG_NO_EXCEPTIONS)
	list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
endif()

34
if(systemd_FOUND)
gabime's avatar
gabime committed
35
	list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
36 37
endif()

38
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
39
enable_testing()
gabime's avatar
gabime committed
40 41 42 43

# The compiled library tests
if(SPDLOG_BUILD_TESTS)
    add_executable(spdlog-utests ${SPDLOG_UTESTS_SOURCES})
44
	spdlog_enable_warnings(spdlog-utests)
gabime's avatar
gabime committed
45
    target_link_libraries(spdlog-utests PRIVATE spdlog)
46 47 48 49

	if(systemd_FOUND)
		target_link_libraries(spdlog-utests PRIVATE ${systemd_LIBRARIES})
	endif()
50 51 52
	if(SPDLOG_SANITIZE_ADDRESS)
		spdlog_enable_sanitizer(spdlog-utests)
	endif()
gabime's avatar
gabime committed
53
    add_test(NAME spdlog-utests COMMAND spdlog-utests)
gabime's avatar
gabime committed
54 55 56
endif()

# The header-only library version tests
57
if(SPDLOG_BUILD_TESTS_HO)
gabime's avatar
gabime committed
58
    add_executable(spdlog-utests-ho ${SPDLOG_UTESTS_SOURCES})
59
	spdlog_enable_warnings(spdlog-utests-ho)
gabime's avatar
gabime committed
60
    target_link_libraries(spdlog-utests-ho PRIVATE spdlog::spdlog_header_only)
61 62 63
	if(systemd_FOUND)
		target_link_libraries(spdlog-utests-ho PRIVATE ${systemd_LIBRARIES})
	endif()
64 65 66
	if(SPDLOG_SANITIZE_ADDRESS)
		spdlog_set_address_sanitizer(spdlog-utests-ho)
	endif()
gabime's avatar
gabime committed
67
    add_test(NAME spdlog-utests-ho COMMAND spdlog-utests-ho)
gabime's avatar
gabime committed
68
endif()