-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (70 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 3.17)
# The name of the CMake project
project(Zia)
# The C++ standard you want to use for your project
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
set(CONAN_DISABLE_CHECK_COMPILER 1)
conan_basic_setup(TARGETS NO_OUTPUT_DIRS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/modules/lib)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/import)
option(ZIA_BUILD_TESTS "When sets to ON, build the unit tests" OFF)
include(FetchZiAPI)
include(FetchYamlCpp)
include(FetchCXXopts)
if(ZIA_BUILD_TESTS)
# The bin name of unit tests
set(BIN unit_tests)
include(FetchGoogleTest)
else()
# The bin name of the project
set(BIN zia)
endif()
# The build flags
if(UNIX)
add_compile_options(-Wall -Wextra -Weffc++)
elseif(WIN32)
add_compile_options(/W4)
endif()
# The location of the main
set(MAIN src/main.cpp)
# The list of source files
set(SOURCES
src/config/ParseYAML.cpp
src/Zia.cpp
src/ModuleLoader.cpp
src/ModulePipeline.cpp
src/ConfigLoader.cpp
src/CLI.cpp
src/RequestManager.cpp
# src/FileWatcher.cpp
)
# The list of tests source files
set(TEST_SOURCES
tests/YamlParserString.cpp
tests/YamlParser.cpp
tests/queues.cpp
)
if(ZIA_BUILD_TESTS)
add_executable(${BIN} ${SOURCES} ${TEST_SOURCES})
enable_testing()
include(GoogleTest)
gtest_discover_tests(${BIN} PROPERTIES TIMEOUT 1200)
target_link_libraries(${BIN} PRIVATE gtest_main)
else()
add_executable(${BIN} ${MAIN} ${SOURCES})
endif()
# The include path of the project
target_include_directories(${BIN} PUBLIC
include
CONAN_INCLUDE_DIRS_ASIO
)
# The lib links of the project
target_link_libraries(${BIN} PRIVATE CONAN_PKG::asio)
target_link_libraries(${BIN} PUBLIC yaml-cpp)
if(UNIX)
target_link_libraries(${BIN} PRIVATE pthread dl)
endif()
add_subdirectory(modules)