opencv/modules/java/CMakeLists.txt

74 lines
2.4 KiB
CMake
Raw Normal View History

2017-12-29 12:15:30 +08:00
if(OPENCV_INITIAL_PASS)
# generator for JNI/JAR source code and documentation signatures
add_subdirectory(generator)
endif()
if(APPLE_FRAMEWORK OR WINRT
OR NOT PYTHON_DEFAULT_AVAILABLE
OR NOT (ANT_EXECUTABLE OR Java_FOUND OR ANDROID_PROJECTS_BUILD_TYPE STREQUAL "GRADLE")
OR NOT (JNI_FOUND OR (ANDROID AND (NOT DEFINED ANDROID_NATIVE_API_LEVEL OR ANDROID_NATIVE_API_LEVEL GREATER 7)))
2014-08-01 22:11:20 +08:00
OR BUILD_opencv_world
)
ocv_module_disable(java)
endif()
set(the_description "The java bindings")
2017-12-29 12:15:30 +08:00
ocv_add_module(java BINDINGS opencv_core opencv_imgproc PRIVATE_REQUIRED opencv_java_bindings_generator)
2011-06-23 23:51:51 +08:00
2017-12-29 12:15:30 +08:00
include(${CMAKE_CURRENT_SOURCE_DIR}/common.cmake)
2015-02-19 21:17:19 +08:00
# UTILITY: glob specific sources and append them to list (type is in H, CPP, JAVA, AIDL)
macro(glob_more_specific_sources _type _root _output)
unset(_masks)
if(${_type} STREQUAL "H")
2020-04-17 19:08:32 +08:00
set(_masks "${_root}/cpp/*.h" "${_root}/cpp/*.hpp")
2015-02-19 21:17:19 +08:00
elseif(${_type} STREQUAL "CPP")
2017-12-29 12:15:30 +08:00
set(_masks "${_root}/cpp/*.cpp")
2015-02-19 21:17:19 +08:00
elseif(${_type} STREQUAL "JAVA")
2017-12-29 12:15:30 +08:00
set(_masks "${_root}/java/*.java" "${_root}/java/*.java.in")
2015-02-19 21:17:19 +08:00
elseif(${_type} STREQUAL "AIDL")
2017-12-29 12:15:30 +08:00
set(_masks "${_root}/java/*.aidl")
2015-02-19 21:17:19 +08:00
endif()
if (_masks)
file(GLOB _result ${_masks})
list(APPEND ${_output} ${_result})
else()
message(WARNING "Bad argument passed to macro: skipped")
endif()
endmacro()
# UTILITY: copy common java test files and add them to _deps
# copy_common_tests(<source-folder> <destination-folder> <variable-to-store-deps>)
macro(copy_common_tests _src_location _dst_location _deps)
2017-12-29 12:15:30 +08:00
set(_src ${_src_location})
set(_dst ${_dst_location})
2015-02-19 21:17:19 +08:00
file(GLOB_RECURSE _files RELATIVE "${_src}" "${_src}/res/*" "${_src}/src/*")
foreach(f ${_files})
add_custom_command(
OUTPUT "${_dst}/${f}"
2015-09-09 03:42:05 +08:00
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_src}/${f}" "${_dst}/${f}"
2015-02-19 21:17:19 +08:00
MAIN_DEPENDENCY "${_src}/${f}"
COMMENT "Copying ${f}")
list(APPEND ${_deps} "${_src}/${f}" "${_dst}/${f}")
endforeach()
unset(_files)
unset(_src)
unset(_dst)
endmacro()
2015-05-20 22:59:42 +08:00
add_subdirectory(jni) # generates ${the_module} target (${the_module}_jni doesn't work properly with Android non-gradle samples)
2011-06-23 23:51:51 +08:00
if(ANDROID)
2017-12-29 12:15:30 +08:00
add_subdirectory(android_sdk) # generates ${the_module}_android target
else()
2017-12-29 12:15:30 +08:00
add_subdirectory(jar) # generates ${the_module}_jar target
endif()
if(BUILD_TESTS)
if(ANDROID)
2017-12-29 12:15:30 +08:00
add_subdirectory(test/android_test)
else()
2017-12-29 12:15:30 +08:00
add_subdirectory(test/pure_test)
endif()
2012-12-20 06:28:59 +08:00
endif()