-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
182 lines (150 loc) · 5.05 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
cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR)
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
# CMakeLists.txt file even before calling the project() command.
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
# command to specify that the current project code is written for the given range of CMake
# versions.
project(libsysstat)
set(MAJOR_VERSION 1)
set(MINOR_VERSION 1)
set(PATCH_VERSION 0)
set(SYSSTAT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
set(LXQTBT_MINIMUM_VERSION "2.1.0")
set(QT_MINIMUM_VERSION "6.6.0")
# additional cmake files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6Core ${QT_MINIMUM_VERSION} REQUIRED)
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt6Core_VERSION}")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # Standard directories for installation
include(LXQtPreventInSourceBuilds)
include(LXQtCreatePkgConfigFile)
include(LXQtCreatePortableHeaders)
include(LXQtCompilerSettings NO_POLICY_SCOPE)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SYSSTAT_LIBRARY_NAME "sysstat-qt6")
set(HEADER_NAMESPACE "SysStat")
set(SYSSTAT_PUBLIC_HDRS
version.h
sysstat_global.h
basestat.h
cpustat.h
memstat.h
netstat.h
)
set(SYSSTAT_PUBLIC_CLASSES
Version
Global
BaseStat
CpuStat
MemStat
NetStat
)
set(SYSSTAT_PRIVATE_HDRS
version_p.h
basestat_p.h
cpustat_p.h
memstat_p.h
netstat_p.h
)
set(SYSSTAT_SRCS
version.cpp
basestat.cpp
cpustat.cpp
memstat.cpp
netstat.cpp
)
set(SYSSTAT_QM_FILES "")
set(APP_SHARE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${SYSSTAT_LIBRARY_NAME}")
add_library(${SYSSTAT_LIBRARY_NAME}
SHARED
${SYSSTAT_PUBLIC_HDRS}
${SYSSTAT_PRIVATE_HDRS}
${SYSSTAT_SRCS}
${SYSSTAT_QM_FILES}
)
target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt6::Core)
set_target_properties(${SYSSTAT_LIBRARY_NAME} PROPERTIES
VERSION ${SYSSTAT_VERSION}
SOVERSION ${MAJOR_VERSION}
)
target_compile_definitions(${SYSSTAT_LIBRARY_NAME}
PRIVATE
"MAJOR_VERSION=${MAJOR_VERSION}"
"MINOR_VERSION=${MINOR_VERSION}"
"PATCH_VERSION=${PATCH_VERSION}"
"SYSSTAT_LIBRARY"
)
target_include_directories(${SYSSTAT_LIBRARY_NAME}
INTERFACE
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}>"
)
lxqt_create_portable_headers(SYSSTAT_NAMESPACE_HEADERS
PATH_PREFIX ".."
HEADER_NAMES ${SYSSTAT_PUBLIC_CLASSES}
)
foreach(h ${SYSSTAT_NAMESPACE_HEADERS})
get_filename_component(bh ${h} NAME)
configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}/${bh}" COPYONLY)
endforeach()
foreach(h ${SYSSTAT_PUBLIC_HDRS})
get_filename_component(bh ${h} NAME)
configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${bh}" COPYONLY)
endforeach()
install(TARGETS
${SYSSTAT_LIBRARY_NAME}
DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT ${SYSSTAT_LIBRARY_NAME}-targets
COMPONENT Runtime
)
install(FILES
${SYSSTAT_PUBLIC_HDRS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}"
COMPONENT Devel
)
install(FILES
${SYSSTAT_NAMESPACE_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}"
COMPONENT Devel
)
#install(FILES ${SYSSTAT_QM_FILES} DESTINATION "${APP_SHARE_DIR}")
export(TARGETS
${SYSSTAT_LIBRARY_NAME}
FILE "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-targets.cmake"
)
lxqt_create_pkgconfig_file(
PACKAGE_NAME ${SYSSTAT_LIBRARY_NAME}
DESCRIPTIVE_NAME ${SYSSTAT_LIBRARY_NAME}
DESCRIPTION "SysStat, a Qt-based interface to system statistics"
INCLUDEDIRS ${SYSSTAT_LIBRARY_NAME}
LIBS ${SYSSTAT_LIBRARY_NAME}
REQUIRES "Qt6Core"
VERSION ${SYSSTAT_VERSION}
INSTALL
)
# cmake config file
set(SYSSTAT_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${SYSSTAT_LIBRARY_NAME}")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/sysstat-config.cmake.in"
"${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}"
)
# cmake version config file
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake"
VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
"${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake"
"${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}"
COMPONENT Devel
)
install(EXPORT
${SYSSTAT_LIBRARY_NAME}-targets
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}"
COMPONENT Devel
)