Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
f0d1e50d
Commit
f0d1e50d
authored
Aug 31, 2021
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmake: Build bpf
parent
a87ea20b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
0 deletions
+70
-0
CMakeLists.txt
CMakeLists.txt
+17
-0
bpf/CMakeLists.txt
bpf/CMakeLists.txt
+13
-0
cmake/FindLibbpf.cmake
cmake/FindLibbpf.cmake
+32
-0
cmakeconfig.h.in
cmakeconfig.h.in
+6
-0
src/CMakeLists.txt
src/CMakeLists.txt
+2
-0
No files found.
CMakeLists.txt
View file @
f0d1e50d
...
...
@@ -64,6 +64,7 @@ find_package(ZLIB 1.2.3)
find_package
(
Libngtcp2 0.0.0
)
find_package
(
Libngtcp2_crypto_openssl 0.0.0
)
find_package
(
Libnghttp3 0.0.0
)
find_package
(
Libbpf 0.4.0
)
if
(
OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND
)
set
(
ENABLE_APP_DEFAULT ON
)
else
()
...
...
@@ -235,6 +236,20 @@ if(ENABLE_ASIO_LIB)
find_package
(
Boost 1.54.0 REQUIRED system thread
)
endif
()
# libbpf (for bpf)
set
(
HAVE_LIBBPF
${
LIBBPF_FOUND
}
)
if
(
LIBBPF_FOUND
)
set
(
BPFCFLAGS -Wall -O2 -g
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Linux"
)
# For Debian/Ubuntu
set
(
EXTRABPFCFLAGS -I/usr/include/
${
CMAKE_SYSTEM_PROCESSOR
}
-linux-gnu
)
endif
()
check_c_source_compiles
(
"
#include <linux/bpf.h>
int main() { enum bpf_stats_type foo; (void)foo; }"
HAVE_BPF_STATS_TYPE
)
endif
()
# The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL and libev
if
(
ENABLE_APP AND
NOT
(
ZLIB_FOUND AND OPENSSL_FOUND AND LIBEV_FOUND
))
message
(
FATAL_ERROR
"Applications were requested (ENABLE_APP=1) but dependencies are not met."
)
...
...
@@ -492,6 +507,7 @@ add_subdirectory(integration-tests)
add_subdirectory
(
doc
)
add_subdirectory
(
contrib
)
add_subdirectory
(
script
)
add_subdirectory
(
bpf
)
string
(
TOUPPER
"
${
CMAKE_BUILD_TYPE
}
"
_build_type
)
...
...
@@ -525,6 +541,7 @@ message(STATUS "summary of build options:
Libngtcp2:
${
HAVE_LIBNGTCP2
}
(LIBS='
${
LIBNGTCP2_LIBRARIES
}
')
Libngtcp2_crypto_openssl:
${
HAVE_LIBNGTCP2_CRYPTO_OPENSSL
}
(LIBS='
${
LIBNGTCP2_CRYPTO_OPENSSL_LIBRARIES
}
')
Libnghttp3:
${
HAVE_LIBNGHTTP3
}
(LIBS='
${
LIBNGHTTP3_LIBRARIES
}
')
Libbpf:
${
HAVE_LIBBPF
}
(LIBS='
${
LIBBPF_LIBRARIES
}
')
Libevent(SSL):
${
HAVE_LIBEVENT_OPENSSL
}
(LIBS='
${
LIBEVENT_OPENSSL_LIBRARIES
}
')
Jansson:
${
HAVE_JANSSON
}
(LIBS='
${
JANSSON_LIBRARIES
}
')
Jemalloc:
${
HAVE_JEMALLOC
}
(LIBS='
${
JEMALLOC_LIBRARIES
}
')
...
...
bpf/CMakeLists.txt
0 → 100644
View file @
f0d1e50d
if
(
LIBBPF_FOUND
)
add_custom_command
(
OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/reuseport_kern.o"
COMMAND
${
CMAKE_C_COMPILER
}
${
BPFCFLAGS
}
${
EXTRABPFCFLAGS
}
-I
${
LIBBPF_INCLUDE_DIRS
}
-target bpf -c reuseport_kern.c -o
"
${
CMAKE_CURRENT_BINARY_DIR
}
/reuseport_kern.o"
WORKING_DIRECTORY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"
VERBATIM
)
add_custom_target
(
bpf ALL
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/reuseport_kern.o"
VERBATIM
)
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/reuseport_kern.o"
DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
/
${
CMAKE_PROJECT_NAME
}
"
)
endif
()
cmake/FindLibbpf.cmake
0 → 100644
View file @
f0d1e50d
# - Try to find libbpf
# Once done this will define
# LIBBPF_FOUND - System has libbpf
# LIBBPF_INCLUDE_DIRS - The libbpf include directories
# LIBBPF_LIBRARIES - The libraries needed to use libbpf
find_package
(
PkgConfig QUIET
)
pkg_check_modules
(
PC_LIBBPF QUIET libbpf
)
find_path
(
LIBBPF_INCLUDE_DIR
NAMES bpf/bpf.h
HINTS
${
PC_LIBBPF_INCLUDE_DIRS
}
)
find_library
(
LIBBPF_LIBRARY
NAMES bpf
HINTS
${
PC_LIBBPF_LIBRARY_DIRS
}
)
include
(
FindPackageHandleStandardArgs
)
# handle the QUIETLY and REQUIRED arguments and set LIBBPF_FOUND
# to TRUE if all listed variables are TRUE and the requested version
# matches.
find_package_handle_standard_args
(
Libbpf REQUIRED_VARS
LIBBPF_LIBRARY LIBBPF_INCLUDE_DIR
VERSION_VAR LIBBPF_VERSION
)
if
(
LIBBPF_FOUND
)
set
(
LIBBPF_LIBRARIES
${
LIBBPF_LIBRARY
}
)
set
(
LIBBPF_INCLUDE_DIRS
${
LIBBPF_INCLUDE_DIR
}
)
endif
()
mark_as_advanced
(
LIBBPF_INCLUDE_DIR LIBBPF_LIBRARY
)
cmakeconfig.h.in
View file @
f0d1e50d
...
...
@@ -81,3 +81,9 @@
/* Define to 1 if HTTP/3 is enabled. */
#cmakedefine ENABLE_HTTP3 1
/* Define to 1 if you have `libbpf` library. */
#cmakedefine HAVE_LIBBPF 1
/* Define to 1 if you have enum bpf_stats_type in linux/bpf.h. */
#cmakedefine HAVE_BPF_STATS_TYPE 1
src/CMakeLists.txt
View file @
f0d1e50d
...
...
@@ -22,6 +22,7 @@ include_directories(
${
LIBCARES_INCLUDE_DIRS
}
${
JANSSON_INCLUDE_DIRS
}
${
ZLIB_INCLUDE_DIRS
}
${
LIBBPF_INCLUDE_DIRS
}
)
# XXX per-target?
...
...
@@ -38,6 +39,7 @@ link_libraries(
${
JANSSON_LIBRARIES
}
${
ZLIB_LIBRARIES
}
${
APP_LIBRARIES
}
${
LIBBPF_LIBRARIES
}
)
if
(
ENABLE_APP
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment