-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
178 lines (162 loc) · 4.99 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
cmake_minimum_required(VERSION 3.14)
project(omphalos VERSION 0.99.14
DESCRIPTION "Network enumeration and domination"
HOMEPAGE_URL "https://nick-black.com/dankwiki/index.php/Omphalos"
LANGUAGES C)
set(CMAKE_C_STANDARD 11)
include(CTest)
include(GNUInstallDirs)
include(FeatureSummary)
###################### USER-SELECTABLE OPTIONS ###########################
option(USE_PANDOC "Use pandoc to write man pages" ON)
option(USE_NOTCURSES "Use Notcurses to build fullscreen UI" ON)
option(USE_READLINE "Use libreadline to build line-based UI" ON)
option(USE_SUDO "Use sudo to bless binaries" OFF)
#################### END USER-SELECTABLE OPTIONS #########################
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build mode." FORCE)
endif()
add_compile_definitions(_FORTIFY_SOURCE=2)
add_compile_options(-Wall -Wextra -W -Wshadow -Wformat -fexceptions)
find_package(PkgConfig REQUIRED)
find_package(Threads)
set_package_properties(Threads PROPERTIES TYPE REQUIRED)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
pkg_check_modules(LIBCAP REQUIRED libcap>=2.24)
pkg_check_modules(LIBNL REQUIRED libnl-3.0>=3.4.0)
pkg_check_modules(LIBNLGENL REQUIRED libnl-genl-3.0>=3.4.0)
pkg_check_modules(LIBPCAP REQUIRED libpcap>=1.9.1)
pkg_check_modules(LIBPCIACCESS REQUIRED pciaccess>=0.13.1)
pkg_check_modules(LIBREADLINE REQUIRED readline)
pkg_check_modules(LIBUDEV REQUIRED libudev>=175)
pkg_check_modules(LIBZ REQUIRED zlib>=1.2.11)
if(${USE_NOTCURSES})
find_package(Notcurses 3.0.0 CONFIG)
set_package_properties(Notcurses PROPERTIES TYPE REQUIRED)
endif()
# don't cache these, or installing them requires clearing the cache to be found.
# this is going to be true for anything lacking pkg-config/CMake support.
unset(HAVE_UNISTRING_H CACHE)
check_include_file("iwlib.h" HAVE_LIBIW_H)
if(NOT "${HAVE_LIBIW_H}")
message(FATAL_ERROR "Couldn't find iwlib.h")
endif()
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND libiw)
set_package_properties(libiw PROPERTIES TYPE REQUIRED)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
include(CMakePackageConfigHelpers)
configure_file(src/version.h.in include/version.h)
set(COMMON_INCLUDE_DIRS
"${LIBCAP_INCLUDE_DIRS}"
"${LIBNL_INCLUDE_DIRS}"
"${LIBNLGENL_INCLUDE_DIRS}"
"${LIBPCAP_INCLUDE_DIRS}"
"${LIBPCIACCESS_INCLUDE_DIRS}"
"${LIBUDEV_INCLUDE_DIRS}"
"${LIBZ_INCLUDE_DIRS}"
)
set(COMMON_LIBRARY_DIRS
"${LIBCAP_LIBRARY_DIRS}"
"${LIBIW_LIBRARY_DIRS}"
"${LIBNL_LIBRARY_DIRS}"
"${LIBNLGENL_LIBRARY_DIRS}"
"${LIBPCAP_LIBRARY_DIRS}"
"${LIBPCIACCESS_LIBRARY_DIRS}"
"${LIBREADLINE_LIBRARY_DIRS}"
"${LIBUDEV_LIBRARY_DIRS}"
"${LIBZ_LIBRARY_DIRS}"
"${Notcurses_LIBRARY_DIRS}"
)
set(COMMON_LIBRARIES
"${LIBCAP_LIBRARIES}"
"${LIBIW_LIBRARIES}"
"${LIBNL_LIBRARIES}"
"${LIBNLGENL_LIBRARIES}"
"${LIBPCAP_LIBRARIES}"
"${LIBPCIACCESS_LIBRARIES}"
"${LIBUDEV_LIBRARIES}"
"${LIBZ_LIBRARIES}"
Threads::Threads
-liw
)
file(GLOB SRCS CONFIGURE_DEPENDS src/omphalos/*.c)
file(GLOB NCSRCS CONFIGURE_DEPENDS src/ui/notcurses/*.c)
file(GLOB RLSRCS CONFIGURE_DEPENDS src/ui/tty/*.c)
file(GLOB CTSRCS CONFIGURE_DEPENDS src/ui/coretest/*.c)
file(GLOB ADDCAPS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/tools/addcaps")
add_executable(omphalos ${SRCS} ${NCSRCS})
add_executable(omphalos-readline ${SRCS} ${RLSRCS})
add_executable(omphalos-coretest ${SRCS} ${CTSRCS})
target_include_directories(omphalos
PRIVATE
src
"${PROJECT_BINARY_DIR}/include"
"${COMMON_INCLUDE_DIRS}"
"${Notcurses_INCLUDE_DIRS}"
)
target_link_libraries(omphalos
PRIVATE
${COMMON_LIBRARIES}
"${Notcurses_LIBRARIES}"
)
target_compile_definitions(omphalos
PRIVATE
_GNU_SOURCE _DEFAULT_SOURCE _XOPEN_SOURCE=600
)
target_include_directories(omphalos-readline
PRIVATE
src
"${PROJECT_BINARY_DIR}/include"
"${COMMON_INCLUDE_DIRS}"
"${LIBREADLINE_INCLUDE_DIRS}"
)
target_link_libraries(omphalos-readline
PRIVATE
${COMMON_LIBRARIES}
${LIBREADLINE_LIBRARIES}
)
target_compile_definitions(omphalos-readline
PRIVATE
_GNU_SOURCE _DEFAULT_SOURCE _XOPEN_SOURCE=600
)
target_include_directories(omphalos-coretest
PRIVATE
src
"${PROJECT_BINARY_DIR}/include"
"${COMMON_INCLUDE_DIRS}"
)
target_link_libraries(omphalos-coretest
PRIVATE
${COMMON_LIBRARIES}
)
target_compile_definitions(omphalos-coretest
PRIVATE
_GNU_SOURCE _DEFAULT_SOURCE _XOPEN_SOURCE=600
)
if(${USE_SUDO})
foreach(o omphalos omphalos-coretest omphalos-readline)
add_custom_command(TARGET ${o}
POST_BUILD COMMAND ${ADDCAPS} ${o}
COMMENT "Blessing ${o}"
)
endforeach()
endif()
file(GLOB PCAPS CONFIGURE_DEPENDS test/*.pcap)
enable_testing()
foreach(p ${PCAPS})
get_filename_component(pe ${p} NAME_WLE)
add_test(
NAME ${pe}
COMMAND omphalos-readline --mode=silent -u "" -f ${p} --plog=plog.pcap --ouis=../ieee-oui.txt
)
endforeach()
add_custom_target(livetest
omphalos -u '' --plog=plog.pcap --ouis=../ieee-oui.txt
)
install(
TARGETS
omphalos
omphalos-readline
DESTINATION
bin
)