From fe8469cc26e895c350bb8f91a9e680f3ed778fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Fri, 19 Jun 2026 12:28:23 +0200 Subject: [PATCH 1/3] highway: add install rules and CMake package config --- highway/CMakeLists.txt | 50 +++++++++++++++++++++++++++-- highway/cmake/fdt_hwConfig.cmake.in | 11 +++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 highway/cmake/fdt_hwConfig.cmake.in diff --git a/highway/CMakeLists.txt b/highway/CMakeLists.txt index de0f4e63..5b36acf5 100644 --- a/highway/CMakeLists.txt +++ b/highway/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.15) project(fdt_hw LANGUAGES CXX) +include(GNUInstallDirs) + option(FDT_HW_BUILD_TESTS "Build hw doctest tests" ON) option(FDT_HW_BUILD_BENCHMARKS "Build hw benchmarks" ON) option(FDT_HW_BUILD_IMAGE_BENCHMARK "Build OpenCV image benchmark" ON) @@ -12,6 +14,8 @@ set(FDT_HW_X86_ARCH "DEFAULT" CACHE STRING "x86 compile ISA: DEFAULT, AVX2, or A set_property(CACHE FDT_HW_X86_ARCH PROPERTY STRINGS DEFAULT AVX2 AVX512) string(TOUPPER "${FDT_HW_X86_ARCH}" FDT_HW_X86_ARCH_UPPER) +SET(BUILD_VERSION "v0.0.3") + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" FDT_HW_SYSTEM_PROCESSOR_LOWER) set(FDT_HW_X86_TARGET OFF) if(FDT_HW_SYSTEM_PROCESSOR_LOWER MATCHES "^(x86_64|amd64|x64|i[3-6]86)$") @@ -84,8 +88,9 @@ add_library(fdt_hw_kernels ) target_include_directories(fdt_hw_kernels PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/src + $ + $ + $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ) @@ -244,3 +249,44 @@ message(STATUS "FDT_HW_FORCE_SCALAR = ${FDT_HW_FORCE_SCALAR}") message(STATUS "FDT_HW_ENABLE_INTRINSICS_COMPARE = ${FDT_HW_ENABLE_INTRINSICS_COMPARE}") message(STATUS "FDT_HW_ENABLE_X86_AVX2 = ${FDT_HW_ENABLE_X86_AVX2}") message(STATUS "FDT_HW_ENABLE_HYBRID_CEILING = ${FDT_HW_ENABLE_HYBRID_CEILING}") + +# --------------------------------------------------------------------------- +# Install + package config so downstream projects can use find_package(fdt_hw). +# +# find_package(fdt_hw REQUIRED CONFIG) +# target_link_libraries(my_app PRIVATE fdt_hw::fdt_hw_kernels) +# +# The generated config re-discovers Highway via find_dependency(hwy), so the +# transitive hwy::hwy link/include usage requirements propagate automatically. +# --------------------------------------------------------------------------- +include(CMakePackageConfigHelpers) + +install(TARGETS fdt_hw_kernels + EXPORT fdt_hwTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/facedetect_hw.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/facedetection) + +install(EXPORT fdt_hwTargets + FILE fdt_hwTargets.cmake + NAMESPACE fdt_hw:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fdt_hw) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/fdt_hwConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/fdt_hwConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fdt_hw) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/fdt_hwConfigVersion.cmake + VERSION ${BUILD_VERSION} + COMPATIBILITY AnyNewerVersion) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/fdt_hwConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/fdt_hwConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fdt_hw) diff --git a/highway/cmake/fdt_hwConfig.cmake.in b/highway/cmake/fdt_hwConfig.cmake.in new file mode 100644 index 00000000..50abe46d --- /dev/null +++ b/highway/cmake/fdt_hwConfig.cmake.in @@ -0,0 +1,11 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# fdt_hw_kernels links Highway as a PUBLIC dependency, so consumers must be able +# to resolve the hwy::hwy imported target before the exported targets are loaded. +find_dependency(hwy 1.3.0) + +include("${CMAKE_CURRENT_LIST_DIR}/fdt_hwTargets.cmake") + +check_required_components(fdt_hw) \ No newline at end of file From cf5d07072dc904d845c123866630a8d81a18f35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Mon, 29 Jun 2026 07:44:07 +0200 Subject: [PATCH 2/3] Address review feedback on PR #384: - Use numeric project version (0.0.3) instead of "v0.0.3" so find_package(fdt_hw 0.0.3 CONFIG) matches; drive the version file from PROJECT_VERSION. - Move facedetect_hw.h under include/facedetection/ and switch all includes, examples, and docs to so build-tree and installed consumers use the same public include path. - Document installing/consuming the module via find_package in COMPILE.md. --- COMPILE.md | 28 ++++++++++++++++++- README.md | 2 +- example/benchmark-highway.cpp | 2 +- example/detect-image-highway.cpp | 2 +- highway/CMakeLists.txt | 8 ++---- highway/benchmark/hw_benchmark.cpp | 2 +- highway/benchmark/hw_image_benchmark.cpp | 2 +- highway/benchmark/hw_resolution_benchmark.cpp | 2 +- highway/docs/hw-plan.md | 2 +- .../{ => facedetection}/facedetect_hw.h | 0 highway/src/facedetect_hw.cpp | 2 +- highway/tests/hw_test_kernels.cpp | 2 +- 12 files changed, 39 insertions(+), 15 deletions(-) rename highway/include/{ => facedetection}/facedetect_hw.h (100%) diff --git a/COMPILE.md b/COMPILE.md index 2e83ad6b..e1bf15ba 100644 --- a/COMPILE.md +++ b/COMPILE.md @@ -148,7 +148,7 @@ for performance experiments and platform-specific builds. It keeps the same external calling style as `facedetect_cnn`, but exposes a separate entry point: ```C++ -#include "facedetect_hw.h" +#include int* results = facedetect_hw_cnn(buffer, bgr_image_data, width, height, step); ``` @@ -272,6 +272,32 @@ The current `hw` implementation follows the same deployment style as the original project: build separately for different instruction sets/platforms instead of using Highway runtime dynamic dispatch. +#### Installing and consuming via `find_package` + +The Highway module can also be installed and consumed as a CMake package. +After installing it, downstream projects discover it with `find_package`: + +```bash +cmake -S highway -B build-hw -DCMAKE_INSTALL_PREFIX= \ + -Dhwy_DIR=/lib/cmake/hwy +cmake --build build-hw +cmake --install build-hw +``` + +```cmake +# In the consumer project, with on CMAKE_PREFIX_PATH: +find_package(fdt_hw 0.0.3 REQUIRED CONFIG) +target_link_libraries(my_app PRIVATE fdt_hw::fdt_hw_kernels) +``` + +```C++ +#include +``` + +The generated package config re-discovers Highway via `find_dependency(hwy)`, so +the transitive `hwy::hwy` include/link requirements propagate to consumers +automatically; no manual include or link wiring is needed. + ### Cross build for aarch64 1. Set cross compiler for aarch64 (please refer to aarch64-toolchain.cmake). diff --git a/README.md b/README.md index 7f470e8f..b01ce9c1 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ An independent Highway-based implementation has been added under `highway/`. It keeps the original implementation untouched and exposes a separate C API: ```C++ -#include "facedetect_hw.h" +#include int* results = facedetect_hw_cnn(result_buffer, bgr_image_data, width, height, step); diff --git a/example/benchmark-highway.cpp b/example/benchmark-highway.cpp index 196b0bf9..113c1687 100644 --- a/example/benchmark-highway.cpp +++ b/example/benchmark-highway.cpp @@ -3,7 +3,7 @@ #include -#include "facedetect_hw.h" +#include #ifdef _OPENMP #include diff --git a/example/detect-image-highway.cpp b/example/detect-image-highway.cpp index a8b074eb..fa680efb 100644 --- a/example/detect-image-highway.cpp +++ b/example/detect-image-highway.cpp @@ -3,7 +3,7 @@ #include -#include "facedetect_hw.h" +#include #define DETECT_BUFFER_SIZE FACEDETECTION_HW_RESULT_BUFFER_SIZE diff --git a/highway/CMakeLists.txt b/highway/CMakeLists.txt index 5b36acf5..208f1f52 100644 --- a/highway/CMakeLists.txt +++ b/highway/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(fdt_hw LANGUAGES CXX) +project(fdt_hw VERSION 0.0.3 LANGUAGES CXX) include(GNUInstallDirs) @@ -14,8 +14,6 @@ set(FDT_HW_X86_ARCH "DEFAULT" CACHE STRING "x86 compile ISA: DEFAULT, AVX2, or A set_property(CACHE FDT_HW_X86_ARCH PROPERTY STRINGS DEFAULT AVX2 AVX512) string(TOUPPER "${FDT_HW_X86_ARCH}" FDT_HW_X86_ARCH_UPPER) -SET(BUILD_VERSION "v0.0.3") - string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" FDT_HW_SYSTEM_PROCESSOR_LOWER) set(FDT_HW_X86_TARGET OFF) if(FDT_HW_SYSTEM_PROCESSOR_LOWER MATCHES "^(x86_64|amd64|x64|i[3-6]86)$") @@ -268,7 +266,7 @@ install(TARGETS fdt_hw_kernels ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/facedetect_hw.h +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/facedetection/facedetect_hw.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/facedetection) install(EXPORT fdt_hwTargets @@ -283,7 +281,7 @@ configure_package_config_file( write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/fdt_hwConfigVersion.cmake - VERSION ${BUILD_VERSION} + VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) install(FILES diff --git a/highway/benchmark/hw_benchmark.cpp b/highway/benchmark/hw_benchmark.cpp index e0fe9781..4bbf1116 100644 --- a/highway/benchmark/hw_benchmark.cpp +++ b/highway/benchmark/hw_benchmark.cpp @@ -1,4 +1,4 @@ -#include "facedetect_hw.h" +#include #include "hw_kernels.h" #include "hw_image.h" #include "hw_network.h" diff --git a/highway/benchmark/hw_image_benchmark.cpp b/highway/benchmark/hw_image_benchmark.cpp index 87008476..51152027 100644 --- a/highway/benchmark/hw_image_benchmark.cpp +++ b/highway/benchmark/hw_image_benchmark.cpp @@ -1,4 +1,4 @@ -#include "facedetect_hw.h" +#include #include "facedetectcnn.h" #include "hw_image.h" #include "hw_model.h" diff --git a/highway/benchmark/hw_resolution_benchmark.cpp b/highway/benchmark/hw_resolution_benchmark.cpp index 75b09d6c..e3682069 100644 --- a/highway/benchmark/hw_resolution_benchmark.cpp +++ b/highway/benchmark/hw_resolution_benchmark.cpp @@ -1,4 +1,4 @@ -#include "facedetect_hw.h" +#include #include "facedetectcnn.h" #include diff --git a/highway/docs/hw-plan.md b/highway/docs/hw-plan.md index a1861632..cbb2715e 100644 --- a/highway/docs/hw-plan.md +++ b/highway/docs/hw-plan.md @@ -360,7 +360,7 @@ The current x64 performance-ceiling path uses Highway packed pointwise plus a hy ## Recommended First Implementation Slice 1. Create `highway/CMakeLists.txt` with `find_package(HWY 1.3.0 CONFIG REQUIRED)`. -2. Add `include/facedetect_hw.h`. +2. Add `include/facedetection/facedetect_hw.h`. 3. Add scalar and Highway primitive kernels. 4. Add doctest kernel equivalence tests. 5. Add `hw_benchmark.cpp` for primitive mode. diff --git a/highway/include/facedetect_hw.h b/highway/include/facedetection/facedetect_hw.h similarity index 100% rename from highway/include/facedetect_hw.h rename to highway/include/facedetection/facedetect_hw.h diff --git a/highway/src/facedetect_hw.cpp b/highway/src/facedetect_hw.cpp index 2a0203e1..b70e26ac 100644 --- a/highway/src/facedetect_hw.cpp +++ b/highway/src/facedetect_hw.cpp @@ -1,4 +1,4 @@ -#include "facedetect_hw.h" +#include #include "hw_image.h" #include "hw_model.h" diff --git a/highway/tests/hw_test_kernels.cpp b/highway/tests/hw_test_kernels.cpp index e4f91525..8013f8d1 100644 --- a/highway/tests/hw_test_kernels.cpp +++ b/highway/tests/hw_test_kernels.cpp @@ -1,7 +1,7 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" -#include "facedetect_hw.h" +#include #include "hw_filter.h" #include "hw_image.h" #include "hw_kernels.h" From ad3b4a32fcb757d2aa0dc6ef40b8a0940ee730c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= Date: Tue, 30 Jun 2026 16:10:05 +0200 Subject: [PATCH 3/3] highway: scope namespaced include to the public API and docs --- highway/CMakeLists.txt | 2 +- highway/benchmark/hw_benchmark.cpp | 2 +- highway/benchmark/hw_image_benchmark.cpp | 2 +- highway/benchmark/hw_resolution_benchmark.cpp | 2 +- highway/docs/hw-plan.md | 2 +- highway/include/{facedetection => }/facedetect_hw.h | 0 highway/src/facedetect_hw.cpp | 2 +- highway/tests/hw_test_kernels.cpp | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename highway/include/{facedetection => }/facedetect_hw.h (100%) diff --git a/highway/CMakeLists.txt b/highway/CMakeLists.txt index 208f1f52..3191978a 100644 --- a/highway/CMakeLists.txt +++ b/highway/CMakeLists.txt @@ -266,7 +266,7 @@ install(TARGETS fdt_hw_kernels ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/facedetection/facedetect_hw.h +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/facedetect_hw.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/facedetection) install(EXPORT fdt_hwTargets diff --git a/highway/benchmark/hw_benchmark.cpp b/highway/benchmark/hw_benchmark.cpp index 4bbf1116..e0fe9781 100644 --- a/highway/benchmark/hw_benchmark.cpp +++ b/highway/benchmark/hw_benchmark.cpp @@ -1,4 +1,4 @@ -#include +#include "facedetect_hw.h" #include "hw_kernels.h" #include "hw_image.h" #include "hw_network.h" diff --git a/highway/benchmark/hw_image_benchmark.cpp b/highway/benchmark/hw_image_benchmark.cpp index 51152027..87008476 100644 --- a/highway/benchmark/hw_image_benchmark.cpp +++ b/highway/benchmark/hw_image_benchmark.cpp @@ -1,4 +1,4 @@ -#include +#include "facedetect_hw.h" #include "facedetectcnn.h" #include "hw_image.h" #include "hw_model.h" diff --git a/highway/benchmark/hw_resolution_benchmark.cpp b/highway/benchmark/hw_resolution_benchmark.cpp index e3682069..75b09d6c 100644 --- a/highway/benchmark/hw_resolution_benchmark.cpp +++ b/highway/benchmark/hw_resolution_benchmark.cpp @@ -1,4 +1,4 @@ -#include +#include "facedetect_hw.h" #include "facedetectcnn.h" #include diff --git a/highway/docs/hw-plan.md b/highway/docs/hw-plan.md index cbb2715e..a1861632 100644 --- a/highway/docs/hw-plan.md +++ b/highway/docs/hw-plan.md @@ -360,7 +360,7 @@ The current x64 performance-ceiling path uses Highway packed pointwise plus a hy ## Recommended First Implementation Slice 1. Create `highway/CMakeLists.txt` with `find_package(HWY 1.3.0 CONFIG REQUIRED)`. -2. Add `include/facedetection/facedetect_hw.h`. +2. Add `include/facedetect_hw.h`. 3. Add scalar and Highway primitive kernels. 4. Add doctest kernel equivalence tests. 5. Add `hw_benchmark.cpp` for primitive mode. diff --git a/highway/include/facedetection/facedetect_hw.h b/highway/include/facedetect_hw.h similarity index 100% rename from highway/include/facedetection/facedetect_hw.h rename to highway/include/facedetect_hw.h diff --git a/highway/src/facedetect_hw.cpp b/highway/src/facedetect_hw.cpp index b70e26ac..2a0203e1 100644 --- a/highway/src/facedetect_hw.cpp +++ b/highway/src/facedetect_hw.cpp @@ -1,4 +1,4 @@ -#include +#include "facedetect_hw.h" #include "hw_image.h" #include "hw_model.h" diff --git a/highway/tests/hw_test_kernels.cpp b/highway/tests/hw_test_kernels.cpp index 8013f8d1..e4f91525 100644 --- a/highway/tests/hw_test_kernels.cpp +++ b/highway/tests/hw_test_kernels.cpp @@ -1,7 +1,7 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" -#include +#include "facedetect_hw.h" #include "hw_filter.h" #include "hw_image.h" #include "hw_kernels.h"