-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
103 lines (84 loc) · 3.37 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
cmake_minimum_required(VERSION 3.15)
project(liblogger LANGUAGES CXX VERSION 1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
include(FetchContent)
add_library(liblogger INTERFACE)
add_library(liblogger::liblogger ALIAS liblogger)
find_package(chalk QUIET)
if (NOT TARGET chalk::chalk)
FetchContent_Declare(chalk GIT_REPOSITORY https://github.com/ebenali/chalk)
FetchContent_GetProperties(chalk)
if (NOT chalk_POPULATED)
FetchContent_Populate(chalk)
add_subdirectory(${chalk_SOURCE_DIR} ${chalk_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
find_package(date QUIET)
if (NOT TARGET date::date)
FetchContent_Declare(hhdate GIT_REPOSITORY https://github.com/HowardHinnant/date)
FetchContent_GetProperties(hhdate)
if (NOT hhdate_POPULATED)
FetchContent_Populate(hhdate)
add_subdirectory(${hhdate_SOURCE_DIR} ${hhdate_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
if(DEFINED ENV{VCPKG_ROOT})
execute_process(COMMAND "$ENV{VCPKG_ROOT}/vcpkg" install --recurse
range-v3
boost-iostreams boost-iostreams[lzma]
gtest boost-lockfree curl
liblzma bzip2 zstd cpptrace)
endif()
message(STATUS "[liblogger] Using system C++20 std::format")
if (NOT TARGET Threads::Threads)
include(FindThreads)
endif()
set(CURL_LIBRARY "-lcurl")
find_package(CURL REQUIRED)
find_package(BZip2 REQUIRED)
find_package(LibLZMA REQUIRED)
find_package(zstd CONFIG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Boost REQUIRED COMPONENTS iostreams)
find_package(cpptrace CONFIG REQUIRED)
find_package(range-v3 CONFIG REQUIRED)
target_link_libraries(liblogger INTERFACE
chalk::chalk date::date
Threads::Threads ${CURL_LIBRARIES}
Boost::boost Boost::iostreams
LibLZMA::LibLZMA
BZip2::BZip2
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
ZLIB::ZLIB
cpptrace::cpptrace
range-v3::meta range-v3::concepts range-v3::range-v3
)
target_include_directories(liblogger INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<INSTALL_INTERFACE:include/liblogger>)
#target_compile_options(liblogger INTERFACE ${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations)
target_sources(liblogger INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/logutil/logutil.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/inspector/inspector.hpp>
$<INSTALL_INTERFACE:>)
set_target_properties(liblogger PROPERTIES PUBLIC_HEADER "logutil/logutil.h;slack/slack.h;inspector/inspector.hpp")
option(LIBLOGGER_COMPILE_EXAMPLE "Compile sample script" ON)
if(LIBLOGGER_COMPILE_EXAMPLE)
add_executable(liblogger-example logutil/logutil_example.cc)
target_link_libraries(liblogger-example PRIVATE liblogger -lrt)
set_target_properties(liblogger-example PROPERTIES OUTPUT_NAME logutil_example)
add_library(example_dylib SHARED logutil/logutil_example_dylib.cc)
target_link_libraries(example_dylib PRIVATE liblogger -lrt)
target_compile_definitions(liblogger-example PRIVATE OVERRIDE_NDEBUG)
target_compile_definitions(example_dylib PRIVATE OVERRIDE_NDEBUG)
endif()
#option(LIBLOGGER_INSTALL "Install liblogger" ON)
#if(LIBLOGGER_INSTALL)
include(GNUInstallDirs)
install(TARGETS liblogger EXPORT liblogger PUBLIC_HEADER DESTINATION include/liblogger)
install(EXPORT liblogger NAMESPACE liblogger:: DESTINATION lib/cmake/liblogger)
# export(EXPORT liblogger NAMESPACE liblogger:: FILE libloggerConfig.cmake)
#endif()
#
#