-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
193 lines (157 loc) · 5.2 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
cmake_minimum_required(VERSION 3.7...3.26)
project(utility C CXX)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CMakePushCheckState)
CMAKE_PUSH_CHECK_STATE(RESET)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_function_exists(renameat2 HAVE_RENAMEAT2)
cmake_pop_check_state()
configure_file(config.h.in config.h)
add_subdirectory(libixxx)
add_subdirectory(libixxxutil)
if((CMAKE_C_COMPILER_ID STREQUAL "GNU"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5")
OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4")
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(NO_SANITIZE "-fno-sanitize=address")
endif()
else()
set(NO_SANITIZE "-fno-sanitize=all")
endif()
check_library_exists(c clock_gettime "" CLOCK_GETTIME_IN_C)
if (CLOCK_GETTIME_IN_C)
set(RT_LIB "")
else()
set(RT_LIB "-lrt")
endif()
add_executable(silence silence.c)
target_compile_definitions(silence PRIVATE _GNU_SOURCE)
add_executable(fail test/fail.c)
add_executable(silencce silence.cc)
target_link_libraries(silencce PRIVATE
ixxxutil_static
ixxx_static
)
add_executable(oldprocs oldprocs.cc)
target_link_libraries(oldprocs PRIVATE
ixxxutil_static
ixxx_static
)
add_executable(lockf lockf.c)
add_executable(dcat dcat.cc)
target_link_libraries(dcat PRIVATE
ixxxutil_static
ixxx_static
)
add_executable(swap swap.c)
target_include_directories(swap PRIVATE ${CMAKE_BINARY_DIR})
add_executable(pargs pargs.c)
target_compile_definitions(pargs PRIVATE _GNU_SOURCE)
add_executable (pargs32 pargs.c)
target_compile_definitions(pargs32 PRIVATE _GNU_SOURCE)
target_compile_options (pargs32 PRIVATE -m32 ${NO_SANITIZE})
target_link_options (pargs32 PRIVATE -m32 ${NO_SANITIZE})
# NOTE: when compiling with sanitizers (address etc.) it's important
# that these test programs are compiled without those flags because
# we need to create some core files of them.
# Apparently, the sanitizing might blow up the core files, i.e. yielding:
# warning: Failed to write corefile contents (No space left on device).
add_executable (snooze test/snooze.c)
target_compile_options(snooze PRIVATE ${NO_SANITIZE})
target_link_options (snooze PRIVATE ${NO_SANITIZE})
add_executable (snooze32 test/snooze.c)
target_compile_options(snooze32 PRIVATE -m32 ${NO_SANITIZE})
target_link_options (snooze32 PRIVATE -m32 ${NO_SANITIZE})
add_executable (busy_snooze test/busy_snooze.c)
target_compile_options(busy_snooze PRIVATE ${NO_SANITIZE})
target_link_options (busy_snooze PRIVATE ${NO_SANITIZE})
target_link_libraries (busy_snooze PRIVATE ${RT_LIB})
add_executable(searchb searchb.c)
add_executable(searchbxx searchb.cc)
target_link_libraries(searchbxx PRIVATE
ixxxutil_static
ixxx_static
)
add_executable(exec exec.c)
add_executable(adjtimex adjtimex.c)
add_executable(pq pq.cc syscalls.cc)
target_link_libraries(pq PRIVATE
ixxxutil_static
ixxx_static
)
add_custom_command(OUTPUT pp_link_stats64.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen_pp_link_stats64.sh
ARGS pp_link_stats64.c
COMMENT "generate rtnl_link_stats64 pretty-printer"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_pp_link_stats64.sh
)
add_custom_target(pp_link_stats64 DEPENDS pp_link_stats64.c)
add_custom_command(OUTPUT csv_link_stats64.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen_csv_link_stats64.py
ARGS csv_link_stats64.c
COMMENT "generate rtnl_link_stats64 csv printer"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_csv_link_stats64.py
)
add_custom_target(csv_link_stats64 DEPENDS csv_link_stats64.c)
add_executable(link_stats64 link_stats64.c)
add_dependencies(link_stats64 pp_link_stats64 csv_link_stats64)
target_include_directories(link_stats64 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
find_package(CURL REQUIRED)
add_executable(hcheck hcheck.c)
target_link_libraries(hcheck PRIVATE CURL::libcurl)
add_custom_target(check-old
COMMAND env src_dir=${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/test/main.py
DEPENDS silence silencce fail lockf
COMMENT "run unittests"
)
add_custom_target(check-new
# work around py.test-3 pytest etc. system differences
COMMAND python3 -m pytest -v
${CMAKE_CURRENT_SOURCE_DIR}/user-installed.py
${CMAKE_CURRENT_SOURCE_DIR}/ascii.py
${CMAKE_CURRENT_SOURCE_DIR}/test/pargs.py
${CMAKE_CURRENT_SOURCE_DIR}/test/dcat.py
DEPENDS dcat pargs pargs32 snooze32 snooze busy_snooze swap
COMMENT "run pytests"
)
add_custom_target(check DEPENDS check-old check-new)
install(TARGETS adjtimex dcat exec hcheck lockf oldprocs pargs pq searchb silence swap
RUNTIME DESTINATION bin)
set(scripts
addrof.sh
arsort.sh
ascii.py
check-cert.py
check-dnsbl.py
chromium-extensions.py
cpufreq.py
detect-size.py
devof.sh
disas.sh
firefox-addons.py
gs-ext.py
inhibit.py
isempty.py
latest-kernel-running.sh
lsata.sh
macgen.py
matrixto.py
pdfmerge.py
pldd.py
pwhatch.sh
remove.py
reset-tmux.sh
ripdvd
unrpm.sh
user-installed.py
wipedev.py
)
foreach(script ${scripts})
STRING(REGEX REPLACE "\\.[^.]*$" "" name ${script})
install(PROGRAMS ${script} DESTINATION bin RENAME ${name})
endforeach()