Merge pull request #6321 from mshabunin:hal_cmake

pull/6335/head
Vadim Pisarevsky 9 years ago
commit 1e1dc1429f
  1. 30
      CMakeLists.txt
  2. 3
      samples/hal/README.md
  3. 10
      samples/hal/c_hal/CMakeLists.txt
  4. 5
      samples/hal/c_hal/config.cmake
  5. 10
      samples/hal/slow_hal/CMakeLists.txt
  6. 5
      samples/hal/slow_hal/config.cmake

@ -603,27 +603,23 @@ endif()
include(cmake/OpenCVDetectVTK.cmake)
# -- Custom HAL replacement --
# Package config in: OpenCV_HALConfig.cmake or opencv_hal-config.cmake
# Use variables: OpenCV_HAL_LIBRARIES, OpenCV_HAL_HEADERS and OpenCV_HAL_INCLUDE_DIRS variables
find_package(OpenCV_HAL CONFIG QUIET)
set(_includes "")
# assuming OPENCV_HAL_HEADERS and OPENCV_HAL_LIBS are lists of files:
# option example: -DOPENCV_HAL_HEADERS="<some-path>/header1.h;<some-path>/header2.h"
if (OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS)
foreach (h ${OPENCV_HAL_HEADERS})
get_filename_component(h "${h}" ABSOLUTE)
set(_includes "${_includes}\n#include \"${h}\"")
endforeach()
foreach (l ${OPENCV_HAL_LIBS})
if (OpenCV_HAL_FOUND)
# 1. libraries
foreach (l ${OpenCV_HAL_LIBRARIES})
get_filename_component(l "${l}" ABSOLUTE)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${l})
# TODO: install?
# ocv_install_target(${l} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
endforeach()
else()
set(_includes "// using default HAL")
unset(OPENCV_HAL_HEADERS CACHE)
unset(OPENCV_HAL_LIBS CACHE)
# 2. headers
foreach (h ${OpenCV_HAL_HEADERS})
set(_includes "${_includes}\n#include \"${h}\"")
endforeach()
# 3. include paths
ocv_include_directories(${OpenCV_HAL_INCLUDE_DIRS})
endif()
set(OPENCV_HAL_HEADERS "${OPENCV_HAL_HEADERS}" CACHE STRING "Headers with custom HAL implementation")
set(OPENCV_HAL_LIBS "${OPENCV_HAL_LIBS}" CACHE STRING "Libraries with custom HAL implementation")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/custom_hal.hpp.in" "${CMAKE_BINARY_DIR}/custom_hal.hpp" @ONLY)
unset(_includes)
@ -1164,7 +1160,7 @@ endif(DEFINED WITH_VA_INTEL)
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)
status(" Use custom HAL:" OPENCV_HAL_HEADERS AND OPENCV_HAL_LIBS THEN "YES (${OPENCV_HAL_HEADERS}; ${OPENCV_HAL_LIBS})" ELSE "NO")
status(" Use custom HAL:" OpenCV_HAL_FOUND THEN "YES (ver ${OpenCV_HAL_VERSION}, ${OpenCV_HAL_CONFIG})" ELSE "NO")
if(HAVE_CUDA)
status("")

@ -23,8 +23,7 @@ Build OpenCV with HAL replacement
2. Go to the created folder and run cmake:
```
cmake \
-DOPENCV_HAL_HEADERS="<opencv-src>/samples/hal/slow_hal/impl.hpp" \
-DOPENCV_HAL_LIBS="<home-dir>/my-hal-build/libslow_hal.a" \
-DOpenCV_HAL_DIR="<home-dir>/my-hal-build/" \
<opencv-src>
```
3. Run make (or `make opencv_perf_core` to build the demonstration test executable only)

@ -1,11 +1,9 @@
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
if(UNIX)
if(CMAKE_COMPILER_IS_GNUC OR CV_ICC)
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
endif()
add_library(c_hal impl.c)
set_target_properties(c_hal PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set(OPENCV_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
target_include_directories(c_hal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${OPENCV_SRC_DIR}/modules/core/include)
configure_file("impl.h" "${CMAKE_BINARY_DIR}/impl.h" COPYONLY)
configure_file("config.cmake" "${CMAKE_BINARY_DIR}/OpenCV_HALConfig.cmake" COPYONLY)

@ -0,0 +1,5 @@
set(OpenCV_HAL_FOUND TRUE)
set(OpenCV_HAL_VERSION "0.0.1")
set(OpenCV_HAL_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/libc_hal.a")
set(OpenCV_HAL_HEADERS "impl.h")
set(OpenCV_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}")

@ -1,11 +1,9 @@
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
endif()
add_library(slow_hal impl.cpp)
set_target_properties(slow_hal PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set(OPENCV_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
target_include_directories(slow_hal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${OPENCV_SRC_DIR}/modules/core/include)
configure_file("impl.hpp" "${CMAKE_BINARY_DIR}/impl.hpp" COPYONLY)
configure_file("config.cmake" "${CMAKE_BINARY_DIR}/OpenCV_HALConfig.cmake" COPYONLY)

@ -0,0 +1,5 @@
set(OpenCV_HAL_FOUND TRUE)
set(OpenCV_HAL_VERSION "0.0.1")
set(OpenCV_HAL_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/libslow_hal.a")
set(OpenCV_HAL_HEADERS "impl.hpp")
set(OpenCV_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}")
Loading…
Cancel
Save