2018-11-06 01:39:09 +08:00
|
|
|
cmake_minimum_required(VERSION 3.6)
|
|
|
|
|
2023-11-17 19:17:17 +08:00
|
|
|
set(target JNIpart)
|
2018-11-06 01:39:09 +08:00
|
|
|
project(${target} CXX)
|
|
|
|
|
2023-11-17 19:17:17 +08:00
|
|
|
if (OPENCV_FROM_SDK)
|
2023-12-01 22:35:06 +08:00
|
|
|
message(STATUS "Using OpenCV from local SDK")
|
2023-11-17 19:17:17 +08:00
|
|
|
set(ANDROID_OPENCV_COMPONENTS "opencv_java" CACHE STRING "")
|
|
|
|
else()
|
2023-12-01 22:35:06 +08:00
|
|
|
message(STATUS "Using OpenCV from AAR (Maven repo)")
|
2023-11-17 19:17:17 +08:00
|
|
|
set(ANDROID_OPENCV_COMPONENTS "OpenCV::opencv_java${OPENCV_VERSION_MAJOR}" CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
|
2018-11-06 01:39:09 +08:00
|
|
|
message(STATUS "ANDROID_ABI=${ANDROID_ABI}")
|
|
|
|
find_package(OpenCV REQUIRED COMPONENTS ${ANDROID_OPENCV_COMPONENTS})
|
2023-12-01 22:35:06 +08:00
|
|
|
find_package(OpenCL QUIET)
|
2018-11-06 01:39:09 +08:00
|
|
|
|
|
|
|
file(GLOB srcs *.cpp *.c)
|
|
|
|
file(GLOB hdrs *.hpp *.h)
|
|
|
|
|
|
|
|
include_directories("${CMAKE_CURRENT_LIST_DIR}")
|
|
|
|
add_library(${target} SHARED ${srcs} ${hdrs})
|
2023-12-01 22:35:06 +08:00
|
|
|
|
|
|
|
target_link_libraries(${target} ${ANDROID_OPENCV_COMPONENTS} -lGLESv2 -lEGL -llog)
|
|
|
|
|
|
|
|
if(OpenCL_FOUND)
|
|
|
|
include_directories(${OpenCL_INCLUDE_DIRS})
|
2023-12-20 21:23:00 +08:00
|
|
|
target_link_libraries(${target} ${OpenCL_LIBRARIES})
|
2023-12-01 22:35:06 +08:00
|
|
|
add_definitions("-DOPENCL_FOUND")
|
2023-12-20 21:23:00 +08:00
|
|
|
elseif(NOT ("${ANDROID_OPENCL_SDK}" STREQUAL ""))
|
2023-12-01 22:35:06 +08:00
|
|
|
include_directories(${ANDROID_OPENCL_SDK}/include)
|
2023-12-20 21:23:00 +08:00
|
|
|
link_directories(${ANDROID_OPENCL_SDK}/lib)
|
|
|
|
target_link_directories(${target} PRIVATE ${ANDROID_OPENCL_SDK}/lib)
|
|
|
|
|
|
|
|
set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--allow-shlib-undefined")
|
|
|
|
target_link_libraries(${target} -lOpenCL)
|
|
|
|
|
2023-12-01 22:35:06 +08:00
|
|
|
add_definitions("-DOPENCL_FOUND")
|
2023-12-20 21:23:00 +08:00
|
|
|
add_definitions("-DCL_HPP_MINIMUM_OPENCL_VERSION=120")
|
|
|
|
add_definitions("-DCL_HPP_TARGET_OPENCL_VERSION=120")
|
|
|
|
add_definitions("-DCL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY")
|
2023-12-01 22:35:06 +08:00
|
|
|
endif()
|