-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (51 loc) · 1.96 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
cmake_minimum_required(VERSION 3.20)
project(AsyncLogger LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "A lightweight C++20 asyncronous logger.")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(PUBLIC_HEADER_DIR "${PROJECT_SOURCE_DIR}/include")
# check std::format support
if(NOT USE_FMT)
include(CheckIncludeFileCXX)
check_include_file_cxx("format" CXX_FORMAT_SUPPORT)
else()
set(CXX_FORMAT_SUPPORT 0)
endif()
file(GLOB_RECURSE SRC_FILES
"${SRC_DIR}/**.cpp"
"${SRC_DIR}/**.hpp"
)
file(GLOB_RECURSE PUBLIC_HEADER_FILES
"${PUBLIC_HEADER_DIR}/**.hpp"
)
# Debug / Release MultiThreaded
if(MSVC)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
)
endif()
add_library(${PROJECT_NAME} STATIC ${SRC_FILES} ${PUBLIC_HEADER_FILES})
if(CXX_FORMAT_SUPPORT)
message(STATUS "Using std::format for formatting, you can set USE_FMT to force fmt::format instead.")
else()
message(STATUS "Using fmt::format for formatting.")
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 9.1.0
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(fmt)
target_link_libraries(${PROJECT_NAME} fmt)
endif()
# does the -lpthread linking for us on Linux
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads )
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 23)
target_include_directories(${PROJECT_NAME} PRIVATE "${PUBLIC_HEADER_DIR}/AsyncLogger/")
target_include_directories(${PROJECT_NAME} PUBLIC "${SRC_DIR}")
target_precompile_headers(${PROJECT_NAME} PRIVATE "${SRC_DIR}/common.hpp")
# public stuff
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADER_FILES}")
target_include_directories(${PROJECT_NAME} PUBLIC "${PUBLIC_HEADER_DIR}")