forked from microsoft/ebpf-for-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
159 lines (128 loc) · 3.3 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
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: MIT
add_subdirectory("ebpf-verifier" EXCLUDE_FROM_ALL)
add_subdirectory("ubpf" EXCLUDE_FROM_ALL)
# Special target that we can link to external dependencies
# to override build settings
add_library("ebpf_for_windows_external_settings" INTERFACE)
target_compile_options("ebpf_for_windows_external_settings" INTERFACE
"/w"
)
target_compile_definitions("ebpf_for_windows_external_settings" INTERFACE
"_CRT_SECURE_NO_WARNINGS"
"_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS"
)
#
# ebpfverifier
#
target_link_libraries("ebpfverifier" PRIVATE
"ebpf_for_windows_external_settings"
)
# Fix missing INTERFACE include directories
target_include_directories("ebpfverifier" INTERFACE
ebpf-verifier/src
ebpf-verifier/external/elfio
)
# Fix missing dependency between ebpfverifier and yaml-cpp
add_dependencies("ebpfverifier"
"yaml-cpp"
)
add_library("external::ebpfverifier" ALIAS "ebpfverifier")
# Some targets end up requiring ebpfverifier by mistake due to
# the ebpf_program_types.h header. For now, create an interface
# target just to export the include directory
add_library("ebpfverifier_headers" INTERFACE)
target_include_directories("ebpfverifier_headers" INTERFACE
ebpf-verifier/src
)
add_library("external::ebpfverifier_headers" ALIAS "ebpfverifier_headers")
#
# boost (downloaded by ebpfverifier)
#
add_library("boost" INTERFACE)
target_include_directories("boost" INTERFACE
"${CMAKE_BINARY_DIR}/packages/boost/lib/native/include"
)
add_library("external::boost" ALIAS "boost")
#
# libbpf
#
# This target has been split from bpftool, since its headers
# are also referenced by the 'api' target
add_library("libbpf"
bpftool/libbpf/src/hashmap.c
bpftool/libbpf/src/libbpf.c
)
target_include_directories("libbpf" PUBLIC
"${CMAKE_SOURCE_DIR}/external/bpftool"
"${CMAKE_SOURCE_DIR}/external/bpftool/libbpf/src"
"${CMAKE_SOURCE_DIR}/external/bpftool/libbpf/include"
"${CMAKE_SOURCE_DIR}/include"
)
target_link_libraries("libbpf"
PRIVATE
"ebpf_for_windows_external_settings"
"ebpf_for_windows_common_settings"
PUBLIC
"external::ebpfverifier"
)
target_compile_definitions("libbpf" PUBLIC
BPFTOOL_VERSION="0.1"
_CONSOLE
)
add_library("external::libbpf" ALIAS "libbpf")
#
# bpftool
#
add_executable("bpftool"
win-c/source/getopt.c
bpftool/src/common.c
bpftool/src/json_writer.c
bpftool/src/link.c
bpftool/src/main.c
bpftool/src/map.c
bpftool/src/net.c
bpftool/src/prog.c
bpftool/src/windows/platform.c
)
target_include_directories("bpftool" PRIVATE
"${CMAKE_SOURCE_DIR}/external/win-c/include"
)
target_link_libraries("bpftool" PRIVATE
"ebpf_for_windows_external_settings"
"ebpf_for_windows_common_settings"
"EbpfApi"
"external::libbpf"
iphlpapi.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
)
add_executable("external::bpftool" ALIAS "bpftool")
codeSign("bpftool")
if(EBPFFORWINDOWS_ENABLE_INSTALL)
install(
TARGETS "bpftool"
DESTINATION "."
)
set(include_dir_list
"asm"
"linux"
"uapi"
)
foreach(include_dir ${include_dir_list})
install(
DIRECTORY "bpftool/libbpf/include/${include_dir}"
DESTINATION "include/libbpf"
)
endforeach()
endif()