-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
150 lines (120 loc) · 4.47 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.7)
project(iqlogger)
set(IQLOGGER_INPUT_MODULES gelf tail journal json dummy)
set(IQLOGGER_OUTPUT_MODULES gelf log)
set(IQLOGGER_STATS_MODULES http telegraf)
set(IQLOGGER_WITH_PROCESSOR ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(DEFINED ENV{IQLOGGER_STATIC_GLIBC})
set(IQLOGGER_STATIC_GLIBC ON)
endif()
file(READ version IQLOGGER_VERSION)
message(STATUS "IQLogger Input Modules: ${IQLOGGER_INPUT_MODULES}")
message(STATUS "IQLogger Output Modules: ${IQLOGGER_OUTPUT_MODULES}")
configure_file (
"${PROJECT_SOURCE_DIR}/src/Version.h.in"
"${PROJECT_BINARY_DIR}/src/Version.h"
)
if (DEFINED ENV{CI_PIPELINE_ID})
set(BUILD_ID "$ENV{CI_PIPELINE_ID}")
else ()
set(BUILD_ID "undefined")
endif ()
message("Build id: ${BUILD_ID}")
if (DEFINED ENV{CI_COMMIT_REF_NAME})
set(BUILD_COMMIT "$ENV{CI_COMMIT_SHA} ($ENV{CI_COMMIT_MESSAGE})")
set(GIT_VERSION "$ENV{CI_COMMIT_REF_NAME}")
else ()
set(BUILD_COMMIT "undefined (undefined)")
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ()
message("Build commit: ${BUILD_COMMIT}")
message("Git version: ${GIT_VERSION}")
string(TIMESTAMP BUILD_DATE_TIME "%Y-%m-%d %H:%M:%S UTC" UTC)
if (DEFINED ENV{CI_USER})
set(BUILD_USER "$ENV{CI_USER}")
else ()
set(BUILD_USER "undefined")
endif ()
message("Build date: ${BUILD_DATE_TIME}")
message("Build user: ${BUILD_USER}")
configure_file (
"${PROJECT_SOURCE_DIR}/src/config/Config.h.in"
"${PROJECT_BINARY_DIR}/src/config/Config.h"
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS system iostreams program_options regex REQUIRED)
if(NOT Boost_FOUND)
message(FATAL "Boost not found!")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CPP_FILESYSTEM_LIB "c++fs")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CPP_FILESYSTEM_LIB "stdc++fs")
set(EC_STATIC_GLIBC ON)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message(FATAL "Intel is not supported!")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(FATAL "MS Visual Studio is not supported!")
endif()
include_directories("${PROJECT_SOURCE_DIR}/src")
include_directories(${Boost_INCLUDE_DIRS})
include(cmake/input.CMakeLists.txt)
include(cmake/output.CMakeLists.txt)
include(cmake/stats.CMakeLists.txt)
add_executable(${PROJECT_NAME} src/main.cpp
src/config/Config.cpp
src/config/core/Core.cpp
src/config/core/QueueOverflowStrategy.cpp
src/config/ConfigManager.cpp
src/config/input/InputConfig.cpp
src/config/output/OutputConfig.cpp
src/config/logger/LoggerConfig.cpp
src/config/processor/ProcessorConfig.cpp
src/config/stats/StatsConfig.cpp
src/MessageQueue.cpp
src/inputs/InputInterface.cpp
src/outputs/OutputInterface.cpp
src/inputs/Input.cpp
src/inputs/IOInput.cpp
src/InputServer.cpp
src/OutputServer.cpp
src/outputs/Output.cpp
src/core/Log.cpp
src/core/Base.cpp
src/metrics/MetricsController.cpp
src/stats/StatsExportServer.cpp
src/IQLogger.cpp
src/MainMessageQueue.cpp
src/formats/gelf/GelfMessage.cpp
)
set(IQLOGGER_LIBS "${IQLOGGER_INPUT_LIBRARIES}${IQLOGGER_OUTPUT_LIBRARIES}${IQLOGGER_STATS_LIBRARIES};${Boost_LIBRARIES};${CPP_FILESYSTEM_LIB};tbb;pthread;z;")
if(IQLOGGER_WITH_PROCESSOR)
message("Processor detected")
add_subdirectory("src/processor")
set(IQLOGGER_LIBS "${PROJECT_NAME}_processor${IQLOGGER_LIBS}")
endif(IQLOGGER_WITH_PROCESSOR)
target_link_libraries(${PROJECT_NAME} ${IQLOGGER_LIBS})
if(IQLOGGER_STATIC_GLIBC)
message("Static linking with libgcc & libstdc++")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
endif()
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "IQLOGGER_LIBS: ${IQLOGGER_LIBS}")
message(STATUS "IQLOGGER Version: ${IQLOGGER_VERSION}")