-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
238 lines (204 loc) · 7.79 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Copyright 2021 Ingemar Hedvall
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.20)
include(CMakePrintHelpers)
if( "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
set(USE_VCPKG OFF)
else()
set(USE_VCPKG ON)
endif()
option(BUILD_SHARED_LIBS "Static libraries are preferred" OFF)
option(UTIL_DOC "If doxygen is installed, then build documentation in Release mode" OFF)
option(UTIL_TOOLS "Building applications" OFF)
option(UTIL_TEST "Building unit test" OFF)
option(UTIL_LEX "Create LEX/BISON" OFF)
#set(CMAKE_FIND_DEBUG_MODE TRUE)
if (UTIL_TOOLS AND USE_VCPKG)
list(APPEND VCPKG_MANIFEST_FEATURES "tools")
endif()
if (UTIL_TEST AND USE_VCPKG)
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_DEBUG_POSTFIX d)
project(utilLib
VERSION 2.0
DESCRIPTION "Common C++ library with utilities."
LANGUAGES CXX)
cmake_print_variables(USE_VCPKG VCPKG_MANIFEST_FEATURES)
include(script/boost.cmake)
include(script/expat.cmake)
include(script/hwinfo.cmake)
if (UTIL_TOOLS)
include(script/wxwidgets.cmake)
endif()
if (UTIL_TEST)
include(script/googletest.cmake)
endif()
if (UTIL_DOC)
include(script/doxygen.cmake)
endif()
if (UTIL_LEX)
include(script/flex.cmake)
include(script/bison.cmake)
endif()
if (BISON_FOUND AND UTIL_LEX)
BISON_TARGET(SYSLOG_PARSER src/syslogparser.y ${CMAKE_CURRENT_SOURCE_DIR}/src/syslogparser.cpp)
cmake_print_variables(BISON_SYSLOG_PARSER_DEFINED
BISON_SYSLOG_PARSER_INPUT
BISON_SYSLOG_PARSER_OUTPUT_SOURCE
BISON_SYSLOG_PARSER_OUTPUT_HEADER
BISON_SYSLOG_PARSER_OUTPUTS
BISON_SYSLOG_PARSER_COMPILE_FLAGS)
endif ()
if (FLEX_FOUND AND UTIL_LEX)
FLEX_TARGET(SYSLOG_SCANNER src/syslogflexer.l ${CMAKE_CURRENT_SOURCE_DIR}/src/syslogflexer.cpp)
cmake_print_variables(FLEX_SYSLOG_SCANNER_DEFINED
FLEX_SYSLOG_SCANNER_OUTPUTS
FLEX_SYSLOG_SCANNER_INPUT
FLEX_SYSLOG_SCANNER_OUTPUT_HEADER)
# Copy FlexLexer.h. This is a dirty trick to avoid flex/bison installation in windows build
file(COPY_FILE ${FLEX_INCLUDE_DIRS}/FlexLexer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/FlexLexer.h)
endif ()
if (FLEX_FOUND AND BISON_FOUND AND UTIL_LEX)
ADD_FLEX_BISON_DEPENDENCY(SYSLOG_SCANNER SYSLOG_PARSER)
endif()
add_library(util
src/logfile.cpp src/logfile.h
include/util/timestamp.h src/timestamp.cpp
include/util/logconfig.h src/logconfig.cpp
include/util/logging.h src/logging.cpp
src/logconsole.cpp src/logconsole.h
include/util/logmessage.h src/logmessage.cpp
include/util/logstream.h src/logstream.cpp
src/expatxml.h src/expatxml.cpp
src/xmlnode.h src/xmlnode.cpp
include/util/ixmlnode.h src/ixmlnode.cpp
include/util/ixmlfile.h src/ixmlfile.cpp
include/util/stringutil.h src/stringutil.cpp
include/util/ilogger.h
include/util/csvwriter.h src/csvwriter.cpp
src/messagequeue.cpp src/messagequeue.h
src/listenmessage.h src/listenmessage.cpp
src/ilisten.cpp include/util/ilisten.h
src/listenserver.cpp src/listenserver.h
src/listenproxy.cpp src/listenproxy.h
include/util/threadsafequeue.h
src/listenserverconnection.h src/listenserverconnection.cpp
src/listenconfig.cpp include/util/listenconfig.h
src/listenclient.cpp src/listenclient.h
src/listenlogger.cpp src/listenlogger.h
src/writexml.cpp src/writexml.h
src/stringparser.cpp include/util/stringparser.h
src/gnuplot.cpp include/util/gnuplot.h
src/tempdir.cpp include/util/tempdir.h
src/syslogmessage.cpp include/util/syslogmessage.h
src/syslog.cpp src/syslog.h src/ilogger.cpp
src/syslogparser.cpp src/syslogparser.hpp
src/syslogflexer.cpp src/FlexLexer.h
src/syslogscanner.cpp src/syslogscanner.h
src/structureddata.cpp include/util/structureddata.h
src/isyslogserver.cpp include/util/isyslogserver.h
src/udpsyslogserver.cpp src/udpsyslogserver.h
src/utilfactory.cpp include/util/utilfactory.h
src/listenconsole.cpp src/listenconsole.h
src/unithelper.cpp include/util/unithelper.h
src/idirectory.cpp include/util/idirectory.h
src/ifile.cpp include/util/ifile.h
src/syslogpublisher.cpp src/syslogpublisher.h
src/syslogconnection.cpp src/syslogconnection.h
src/syslogsubscriber.cpp src/syslogsubscriber.h
src/tcpsyslogserver.cpp src/tcpsyslogserver.h
src/ilistenclient.cpp include/util/ilistenclient.h
src/serialportinfo.cpp include/util/serialportinfo.h
src/serialportinfowin.inc
src/ihwinfo.cpp include/util/ihwinfo.h
)
target_include_directories(util PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_include_directories(util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(util PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(util PRIVATE ${EXPAT_INCLUDE_DIRS})
target_include_directories(util PRIVATE ${hwinfo_SOURCE_DIR}/include)
cmake_print_properties(TARGETS util PROPERTIES INCLUDE_DIRECTORIES)
target_compile_definitions(util PRIVATE XML_STATIC)
if (MSVC)
target_compile_definitions(util PRIVATE _WIN32_WINNT=0x0A00)
endif ()
set(UTIL_PUBLIC_HEADERS
include/util/csvwriter.h
include/util/gnuplot.h
include/util/idirectory.h
include/util/ifile.h
include/utililisten.h
include/util/ilistenclient.h
include/util/ilogger.h
include/util/isyslogserver.h
include/util/ixmlfile.h
include/util/ixmlnode.h
include/util/listenconfig.h
include/util/logconfig.h
include/util/logging.h
include/util/logmessage.h
include/util/logstream.h
include/util/serialportinfo.h
include/util/stringparser.h
include/util/stringutil.h
include/util/structureddata.h
include/util/syslogmessage.h
include/util/tempdir.h
include/util/threadsafequeue.h
include/util/timestamp.h
include/util/unithelper.h
include/util/utilfactory.h
include/util/redicconnection.h
)
set_target_properties(util PROPERTIES PUBLIC_HEADER "${UTIL_PUBLIC_HEADERS}")
get_target_property(PH util PUBLIC_HEADER)
message(STATUS "UTIL Target Includes: " "${PH}")
if (UTIL_TOOLS)
add_subdirectory(listend)
endif ()
if (WIN32 AND UTIL_TOOLS)
add_subdirectory(serviced)
endif ()
if (wxWidgets_FOUND AND UTIL_TOOLS)
add_subdirectory(listenviewer)
endif ()
if (wxWidgets_FOUND AND WIN32 AND UTIL_TOOLS)
add_subdirectory(serviceexplorer)
endif ()
if (UTIL_TEST)
enable_testing()
add_subdirectory(test)
endif ()
if (DOXYGEN_FOUND AND (CMAKE_BUILD_TYPE MATCHES "^[Rr]elease") AND UTIL_DOC)
set(DOXYGEN_RECURSIVE NO)
set(DOXYGEN_REPEAT_BRIEF NO)
set(DOXYGEN_PROJECT_NAME "UTILLib")
set(DOXYGEN_HTML_EXTRA_STYLESHEET doxygen/utillib.css)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs/manual)
doxygen_add_docs(doc_libutil ALL
include/util doxygen
COMMENT "Util Library generating API documentation with Doxygen")
endif ()
install(TARGETS util
EXPORT UtilLibTargets
LIBRARY DESTINATION util/lib
ARCHIVE DESTINATION util/lib
RUNTIME DESTINATION util/bin
PUBLIC_HEADER DESTINATION util/include/util)
#include(CMakePackageConfigHelpers)
#write_basic_package_version_file(
# UtilLibConfigVersion.cmake
# VERSION ${PACKAGE_VERSION}
# COMPATIBILITY AnyNewerVersion)
#
#install(EXPORT UtilLibTargets
# FILE UtilLibTargets.cmake
# NAMESPACE UtilLib::
# DESTINATION lib/cmake/UtilLib
# )
#export(TARGETS util NAMESPACE UtilLib:: FILE UtilLibTargets.cmake)