@ -1,14 +1,23 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# C M a k e f i l e f o r j a v a s u p p o r t
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ( NOT ANDROID OR NOT PYTHON_EXECUTABLE OR ANDROID_NATIVE_API_LEVEL LESS 8 )
if ( IOS OR NOT PYTHON_EXECUTABLE OR NOT ( JNI_FOUND OR ( ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7 ) ) )
ocv_module_disable ( java )
endif ( )
if ( NOT ANDROID )
# d i s a b l e j a v a b y d e f a u l t b e c a u s e j a v a s u p p o r t o n d e s k t o p i s e x p e r i m e n t a l
set ( BUILD_opencv_java_INIT OFF )
endif ( )
set ( the_description "The java bindings" )
ocv_add_module ( java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo opencv_nonfree opencv_contrib )
ocv_module_include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp" )
if ( NOT ANDROID )
include_directories ( ${ JNI_INCLUDE_DIRS } )
endif ( )
# g e t l i s t o f m o d u l e s t o w r a p
string ( REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS};${OPENCV_MODULE_${the_module}_OPT_DEPS}" )
foreach ( module ${ OPENCV_JAVA_MODULES } )
@ -123,7 +132,12 @@ set(JNI_INSTALL_ROOT "sdk/native")
# c o p y e a c h d o c u m e n t e d h e a d e r t o t h e f i n a l d e s t i n a t i o n
set ( java_files "" )
foreach ( java_file ${ documented_java_files } ${ handwrittren_aidl_sources } )
set ( source_java_files ${ documented_java_files } ${ handwrittren_aidl_sources } )
if ( NOT ANDROID )
ocv_list_filterout ( source_java_files "/(engine|android)\\\\+" )
endif ( )
foreach ( java_file ${ source_java_files } )
get_filename_component ( java_file_name "${java_file}" NAME )
string ( REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}" )
string ( REPLACE "+" "/" java_file_name "${java_file_name}" )
@ -175,6 +189,7 @@ set_target_properties(${the_module} PROPERTIES
install ( TARGETS ${ the_module } LIBRARY DESTINATION ${ OPENCV_LIB_INSTALL_PATH } COMPONENT main )
set ( lib_target ${ the_module } _library )
if ( ANDROID )
target_link_libraries ( ${ the_module } jnigraphics ) # f o r M a t < = > B i t m a p c o n v e r t e r s
@ -223,8 +238,6 @@ if(ANDROID)
# c r e a t e A n d r o i d l i b r a r y p r o j e c t i n b u i l d f o l d e r
if ( ANDROID_EXECUTABLE )
set ( lib_target ${ the_module } _android_library )
set ( lib_target_files ${ ANDROID_LIB_PROJECT_FILES } )
ocv_list_add_prefix ( lib_target_files "${OpenCV_BINARY_DIR}/" )
@ -263,12 +276,26 @@ if(ANDROID)
endif ( )
add_custom_target ( ${ lib_target } SOURCES ${ lib_proj_files } ${ lib_target_files } "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" )
add_dependencies ( ${ lib_target } ${ api_target } )
add_dependencies ( ${ the_module } ${ lib_target } )
endif ( )
else ( ANDROID )
configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/jar/build.xml" "${OpenCV_BINARY_DIR}/build.xml" IMMEDIATE @ONLY )
set ( JAR_NAME opencv- ${ OPENCV_VERSION_MAJOR } . ${ OPENCV_VERSION_MINOR } . ${ OPENCV_VERSION_PATCH } .jar )
add_custom_command (
O U T P U T " $ { O p e n C V _ B I N A R Y _ D I R } / b i n / $ { J A R _ N A M E } " " $ { O p e n C V _ B I N A R Y _ D I R } / b i n / . $ { J A R _ N A M E } . d e p h e l p e r "
C O M M A N D $ { A N T _ E X E C U T A B L E } - q - n o i n p u t - k j a r
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h " $ { O p e n C V _ B I N A R Y _ D I R } / b i n / . $ { J A R _ N A M E } . d e p h e l p e r "
W O R K I N G _ D I R E C T O R Y " $ { O p e n C V _ B I N A R Y _ D I R } "
D E P E N D S " $ { O p e n C V _ B I N A R Y _ D I R } / b u i l d . x m l " $ { j a v a _ f i l e s }
C O M M E N T " G e n e r a t i n g $ { J A R _ N A M E } "
)
add_custom_target ( ${ lib_target } SOURCES "${OpenCV_BINARY_DIR}/bin/${JAR_NAME}" )
endif ( ANDROID )
add_dependencies ( ${ lib_target } ${ api_target } )
add_dependencies ( ${ the_module } ${ lib_target } )
# a n d r o i d t e s t p r o j e c t
if ( ANDROID AND BUILD_TESTS )
add_subdirectory ( android_test )