diff --git a/3rdparty/kleidicv/CMakeLists.txt b/3rdparty/kleidicv/CMakeLists.txt index 060357662c..a236483c27 100644 --- a/3rdparty/kleidicv/CMakeLists.txt +++ b/3rdparty/kleidicv/CMakeLists.txt @@ -1,24 +1,7 @@ project(kleidicv_hal) -set(KLEIDICV_SOURCE_PATH "" CACHE PATH "Directory containing KleidiCV sources") -ocv_update(KLEIDICV_SRC_COMMIT "0.2.0") -ocv_update(KLEIDICV_SRC_HASH "dabe522e8f55ac342d07a787391dab80") - -if(KLEIDICV_SOURCE_PATH) - set(THE_ROOT "${KLEIDICV_SOURCE_PATH}") -else() - ocv_download(FILENAME "kleidicv-${KLEIDICV_SRC_COMMIT}.tar.gz" - HASH ${KLEIDICV_SRC_HASH} - URL - "${OPENCV_KLEIDICV_URL}" - "$ENV{OPENCV_KLEIDICV_URL}" - "https://gitlab.arm.com/kleidi/kleidicv/-/archive/${KLEIDICV_SRC_COMMIT}/" - DESTINATION_DIR "${OpenCV_BINARY_DIR}/3rdparty/kleidicv/" - ID KLEIDICV - STATUS res - UNPACK RELATIVE_URL) - set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/kleidicv/kleidicv-${KLEIDICV_SRC_COMMIT}") +if(HAVE_KLEIDICV) + option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK + include("${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt") endif() -option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK -include("${THE_ROOT}/adapters/opencv/CMakeLists.txt") diff --git a/3rdparty/kleidicv/kleidicv.cmake b/3rdparty/kleidicv/kleidicv.cmake new file mode 100644 index 0000000000..57d3843ef0 --- /dev/null +++ b/3rdparty/kleidicv/kleidicv.cmake @@ -0,0 +1,21 @@ +function(download_kleidicv root_var) + set(${root_var} "" PARENT_SCOPE) + + ocv_update(KLEIDICV_SRC_COMMIT "0.2.0") + ocv_update(KLEIDICV_SRC_HASH "dabe522e8f55ac342d07a787391dab80") + + set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/kleidicv") + ocv_download(FILENAME "kleidicv-${KLEIDICV_SRC_COMMIT}.tar.gz" + HASH ${KLEIDICV_SRC_HASH} + URL + "${OPENCV_KLEIDICV_URL}" + "$ENV{OPENCV_KLEIDICV_URL}" + "https://gitlab.arm.com/kleidi/kleidicv/-/archive/${KLEIDICV_SRC_COMMIT}/" + DESTINATION_DIR ${THE_ROOT} + ID KLEIDICV + STATUS res + UNPACK RELATIVE_URL) + if(res) + set(${root_var} "${OpenCV_BINARY_DIR}/3rdparty/kleidicv/kleidicv-${KLEIDICV_SRC_COMMIT}" PARENT_SCOPE) + endif() +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index c8e4ef09c3..3520e92e06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -935,7 +935,7 @@ if(HAVE_OPENVX) endif() endif() -if(WITH_KLEIDICV) +if(HAVE_KLEIDICV) ocv_debug_message(STATUS "Enable KleidiCV acceleration") if(NOT ";${OpenCV_HAL};" MATCHES ";kleidicv;") set(OpenCV_HAL "kleidicv;${OpenCV_HAL}") diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 5f72a67d89..493f005d7a 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -161,3 +161,19 @@ if(WITH_CLP) endif() endif() endif(WITH_CLP) + +# --- ARM KleidiCV +if(WITH_KLEIDICV) + if(KLEIDICV_SOURCE_PATH AND EXISTS "${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt") + set(HAVE_KLEIDICV ON) + endif() + if(NOT HAVE_KLEIDICV) + include("${OpenCV_SOURCE_DIR}/3rdparty/kleidicv/kleidicv.cmake") + download_kleidicv(KLEIDICV_SOURCE_PATH) + if(KLEIDICV_SOURCE_PATH) + set(HAVE_KLEIDICV ON) + endif() + else() + set(HAVE_KLEIDICV OFF) + endif() +endif(WITH_KLEIDICV)