Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <facedetection/facedetect_hw.h>

int* results = facedetect_hw_cnn(buffer, bgr_image_data, width, height, step);
```
Expand Down Expand Up @@ -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=<prefix> \
-Dhwy_DIR=<path-to-highway>/lib/cmake/hwy
cmake --build build-hw
cmake --install build-hw
```

```cmake
# In the consumer project, with <prefix> 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 <facedetection/facedetect_hw.h>
```

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).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <facedetection/facedetect_hw.h>

int* results = facedetect_hw_cnn(result_buffer, bgr_image_data,
width, height, step);
Expand Down
2 changes: 1 addition & 1 deletion example/benchmark-highway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <opencv2/opencv.hpp>

#include "facedetect_hw.h"
#include <facedetection/facedetect_hw.h>

#ifdef _OPENMP
#include <omp.h>
Expand Down
2 changes: 1 addition & 1 deletion example/detect-image-highway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <opencv2/opencv.hpp>

#include "facedetect_hw.h"
#include <facedetection/facedetect_hw.h>

#define DETECT_BUFFER_SIZE FACEDETECTION_HW_RESULT_BUFFER_SIZE

Expand Down
50 changes: 47 additions & 3 deletions highway/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.15)

project(fdt_hw LANGUAGES CXX)
project(fdt_hw VERSION 0.0.3 LANGUAGES CXX)

include(GNUInstallDirs)

option(FDT_HW_BUILD_TESTS "Build hw doctest tests" ON)
option(FDT_HW_BUILD_BENCHMARKS "Build hw benchmarks" ON)
Expand Down Expand Up @@ -84,8 +86,9 @@ add_library(fdt_hw_kernels
)
target_include_directories(fdt_hw_kernels
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
Expand Down Expand Up @@ -244,3 +247,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 ${PROJECT_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)
11 changes: 11 additions & 0 deletions highway/cmake/fdt_hwConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -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)