-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: modify build system for OpenWrt compatibility #172
base: main
Are you sure you want to change the base?
Conversation
- Disable testing and documentation builds by default - Add conditional inclusion of tests and documentation - Handle argp dependency with find_library - Make development tools (clang-tidy, clang-format) optional - Add flexible bpftool handling with fallback paths - Improve build system modularity and configurability This modification adjusts the build system to ensure compatibility with the OpenWrt environment, making necessary changes for a successful build. Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
Hi @liudf0716! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
option(BUILD_TESTING "Enable testing" OFF) | ||
option(BUILD_DOCS "Enable building documentation" OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should be enabled by default to keep the current behaviour. Use WITH_XXX
instead of BUILD_XXX
similarly to #174.
option(BUILD_DOCS "Enable building documentation" OFF) | ||
|
||
if(BUILD_DOCS) | ||
find_package(Doxygen REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this in docs/CMakeLists.txt
, and modify add_subdirectory(docs)
below to:
if (WITH_DOCS)
add_subdirectory(docs)
endif ()
if(BUILD_TESTING) | ||
pkg_check_modules(cmocka REQUIRED IMPORTED_TARGET cmocka) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
pkg_check_modules(nl REQUIRED IMPORTED_TARGET libnl-3.0) | ||
|
||
find_library(ARGP_LIBRARY | ||
NAMES argp | ||
PATHS ${CMAKE_SYSROOT}/usr/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to CMake's doc, search path are automatically prefixed with CMAKE_SYSROOT
, so there is no need to add it here.
if(NOT ARGP_LIBRARY) | ||
message(FATAL_ERROR "libargp not found") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARGP_LIBRARY
is REQUIRED
above, if not found, CMake will fail the generation and print an error message, no need for this condition.
if(BUILD_DOCS) | ||
find_program(SPHINX_BIN sphinx-build REQUIRED) | ||
find_program(LCOV_BIN lcov REQUIRED) | ||
find_program(GENHTML_BIN genhtml REQUIRED) | ||
find_program(CLANG_TIDY_BIN NAMES clang-tidy-18 clang-tidy REQUIRED) | ||
find_program(CLANG_FORMAT_BIN NAMES clang-format-18 clang-format REQUIRED) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All those find_program
should be located in docs/CMakeLists.txt
.
@@ -80,7 +78,7 @@ extern const char *strerrordesc_np(int errnum); | |||
* | |||
* @param v Error code, can be positive or negative. | |||
*/ | |||
#define bf_strerror(v) strerrordesc_np(abs(v)) | |||
#define bf_strerror(v) strerror(abs(v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
find_program(CLANG_TIDY_BIN NAMES clang-tidy-18 clang-tidy REQUIRED) | ||
find_program(CLANG_FORMAT_BIN NAMES clang-format-18 clang-format REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those two binaries are not part of the documentation generation, but the testing logic.
# Replace mandatory REQUIRED flag | ||
find_program(BPFTOOL_BIN bpftool) | ||
|
||
# Add fallback paths | ||
if(NOT BPFTOOL_BIN) | ||
find_program(BPFTOOL_BIN bpftool | ||
PATHS | ||
${CMAKE_SYSROOT}/usr/sbin | ||
${CMAKE_SYSROOT}/sbin | ||
/usr/sbin | ||
/sbin | ||
) | ||
endif() | ||
|
||
# Make it optional with warning | ||
if(NOT BPFTOOL_BIN) | ||
message(WARNING "bpftool not found - some features may be disabled") | ||
set(BPFTOOL_BIN "bpftool") # Set default value | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to tests/bpf/CMakeLists.txt
, where bpftool
is actually used. It's not ideal, but better than the current situation and probably sufficient for your use case.
Thanks for the PR @liudf0716 ! I've recently modified the benchmarking configuration similarly to this PR, see #174 for a example of what I'm looking for. Long story short:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating status
Disable testing and documentation builds by default
This modification adjusts the build system to ensure compatibility
with the OpenWrt environment, making necessary changes for a successful build.
Signed-off-by: Dengfeng Liu liudf0716@gmail.com