@ -1,16 +1,15 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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 )
if ( NOT ANDROID OR NOT PYTHON_EXECUTABLE OR ANDROID_NATIVE_API_LEVEL LESS 8 )
ocv_module_disable ( java )
endif ( )
set ( OPENCV_MODULES_EXPORTED_TO_JAVA opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo CACHE STRING "List of modules exported to Java API" )
mark_as_advanced ( OPENCV_MODULES_EXPORTED_TO_JAVA )
set ( the_description "The java bindings" )
ocv_add_module ( java BINDINGS opencv_core opencv_imgproc OPTIONAL ${ OPENCV_MODULES_EXPORTED_TO_JAVA } )
ocv_add_module ( java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo )
ocv_module_include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp" )
# 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 } )
if ( NOT HAVE_opencv_ ${ module } )
@ -18,78 +17,71 @@ foreach(module ${OPENCV_JAVA_MODULES})
endif ( )
endforeach ( )
set ( target ${ the_module } )
ocv_include_directories ( "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp" )
set ( GEN_JAVA "${CMAKE_CURRENT_SOURCE_DIR}/gen_java.py" )
set ( HDR_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/../python/src2/hdr_parser.py" )
set ( GEN_JAVADOC "${CMAKE_CURRENT_SOURCE_DIR}/gen_javadoc.py" )
set ( RST_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/rst_parser.py" )
set ( CHECK_TEST_COVERAGE "${CMAKE_CURRENT_SOURCE_DIR}/check-tests.py" )
# a d d d e p e n d e n c i e s t o cmake ( we should rerun cmake if any of these scripts is modified )
configure_file ( "${GEN_JAVA}" "${CMAKE_BINARY_DIR}/junk/gen_java.junk" COPYONLY )
configure_file ( "${HDR_PARSER}" "${CMAKE_BINARY_DIR}/junk/hdr_parser.junk" COPYONLY )
set ( java_hdr_deps "" )
set ( generated_cpp_sources "" )
set ( generated_java_sources "" )
# s e t u p r a w j a v a a n d c p p f i l e s generation ( without javadoc and at temporary location )
foreach ( module ${ OPENCV_JAVA_MODULES } )
# g e t l i s t o f m o d u l e h e a d e r s
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist" )
file ( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist" headers_to_parse )
set ( module_cheaders "" )
set ( module_cppheaders "" )
foreach ( header ${ headers_to_parse } )
list ( APPEND module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/${header}" )
endforeach ( )
file ( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/config/${module}.filelist" module_headers )
ocv_list_add_prefix ( module_headers "${OPENCV_MODULE_opencv_${module}_LOCATION}/" )
else ( )
file ( GLOB module_cheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.h" )
file ( GLOB module_cppheaders "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include/opencv2/${module}/*.hpp" )
list ( SORT module_cheaders )
list ( SORT module_cppheaders )
set ( module_headers "${OPENCV_MODULE_opencv_${module}_HEADERS}" )
endif ( )
# C h e a d e r s m u s t g o f i r s t
set ( module_headers_cpp ${ module_headers } )
ocv_list_filterout ( module_headers_cpp "\\\\.h$" )
if ( module_headers_cpp )
list ( REMOVE_ITEM module_headers ${ module_headers_cpp } )
list ( APPEND module_headers ${ module_headers_cpp } )
endif ( )
unset ( module_headers_cpp )
# a d d d e p e n d e n c i e s t o cmake ( we should rerun cmake if any of these headers is modified )
foreach ( header ${ module_cheaders } ${ module_cppheaders } )
foreach ( header ${ module_headers } )
get_filename_component ( header_name "${header}" NAME_WE )
configure_file ( "${header}" "${CMAKE_BINARY_DIR}/junk/${header_name}.junk" COPYONLY )
endforeach ( )
# t h e s a m e a b o u t g e n _ j a v a . p y a n d h d r _ p a r s e r . p y
configure_file ( "${GEN_JAVA}" "${CMAKE_BINARY_DIR}/junk/gen_java.junk" COPYONLY )
configure_file ( "${HDR_PARSER}" "${CMAKE_BINARY_DIR}/junk/hdr_parser.junk" COPYONLY )
# f i r s t run ( to get list of generated files )
file ( REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" )
file ( MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out" )
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } "${GEN_JAVA}" "${HDR_PARSER}" ${ module } ${ module_cheaders } ${ module_cpp headers }
execute_process ( COMMAND ${ PYTHON_EXECUTABLE } "${GEN_JAVA}" "${HDR_PARSER}" ${ module } ${ module_headers }
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g e n _ j a v a _ o u t "
O U T P U T _ Q U I E T E R R O R _ Q U I E T )
file ( GLOB_RECURSE ${ module } _generated_java_sources RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/*.java" )
ocv_list_add_prefix ( ${ module } _generated_java_sources "${CMAKE_CURRENT_BINARY_DIR}/" )
# c r e a t e l i s t o f g e n e r a t e d f i l e s
file ( GLOB_RECURSE generated_java_sources RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/*.java" )
file ( REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/" )
set ( ${ module } _generated_java_sources )
foreach ( f ${ generated_java_sources } )
list ( APPEND ${ module } _generated_java_sources "${CMAKE_CURRENT_BINARY_DIR}/${f}" )
endforeach ( )
# s e c o n d run ( at build time )
add_custom_command ( OUTPUT ${ ${module } _generated_java_sources} "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp"
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } " $ { G E N _ J A V A } " " $ { H D R _ P A R S E R } " $ { m o d u l e } $ { m o d u l e _ h e a d e r s }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S " $ { G E N _ J A V A } " " $ { H D R _ P A R S E R } " $ { m o d u l e _ h e a d e r s } )
# s e c o n d r u n
add_custom_command (
O U T P U T $ { $ { m o d u l e } _ g e n e r a t e d _ j a v a _ s o u r c e s }
O U T P U T " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { m o d u l e } . c p p "
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } " $ { G E N _ J A V A } " " $ { H D R _ P A R S E R } " $ { m o d u l e } $ { m o d u l e _ c h e a d e r s } $ { m o d u l e _ c p p h e a d e r s }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S " $ { G E N _ J A V A } "
D E P E N D S " $ { H D R _ P A R S E R } "
D E P E N D S $ { m o d u l e _ c h e a d e r s }
D E P E N D S $ { m o d u l e _ c p p h e a d e r s }
)
list ( APPEND java_hdr_deps ${ module_headers } )
list ( APPEND generated_cpp_sources "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp" )
list ( APPEND generated_java_sources ${ ${module } _generated_java_sources} )
endforeach ( )
file ( GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp" )
# g e t h a n d w r i t t e n f i l e s u s e d f o r w r a p p e r s g e n e r a t i o n
file ( GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.hpp" )
file ( GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp" )
file ( GLOB handwrittren_java_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/java/*.java" )
set ( generated_cpp_sources )
set ( generated_java_sources )
set ( documented_java_files )
set ( undocumented_java_files )
# r e m o v e h a n d w r i t t e n j a v a f i l e s f o r d i s a b l e d m o d u l e s
foreach ( jfile ${ handwrittren_java_sources } )
string ( REGEX REPLACE "^.*/([^+]+)\\+.*\\.java$" "\\1" jmodname "${jfile}" )
if ( DEFINED HAVE_opencv_ ${ jmodname } AND NOT HAVE_opencv_ ${ jmodname } )
@ -97,42 +89,36 @@ foreach(jfile ${handwrittren_java_sources})
endif ( )
endforeach ( )
foreach ( module ${ OPENCV_JAVA_MODULES } )
list ( APPEND generated_cpp_sources "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp" )
list ( APPEND generated_java_sources ${ ${module } _generated_java_sources} )
endforeach ( )
# a l l n e e d e d i n c l u d e s
foreach ( module ${ OPENCV_MODULE_${the_module } _DEPS} )
string ( REPLACE "opencv_" "" module "${module}" )
ocv_include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include" )
endforeach ( )
# r e m o v e V i d e o C a p t u r e w r a p p e r i f h i g h g u i i s d i s a b l e d
if ( NOT HAVE_opencv_highgui )
list ( REMOVE_ITEM handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/VideoCapture.cpp" )
endif ( )
# c r e a t e d l i s t o f d o c u m e n t e d f i l e s t a r g e t s
# c r e a t e l i s t o f j a v a d o c d o c u m e n t e d f i l e s
unset ( documented_java_files )
foreach ( java_file ${ handwrittren_java_sources } ${ generated_java_sources } )
get_filename_component ( java_file_name "${java_file}" NAME_WE )
if ( NOT java_file_name MATCHES ".*-jdoc$" )
list ( APPEND documented_java_files "${CMAKE_CURRENT_BINARY_DIR}/${java_file_name}-jdoc.java" )
list ( APPEND undocumented_java_files "${java_file}" )
endif ( )
list ( APPEND documented_java_files "${CMAKE_CURRENT_BINARY_DIR}/${java_file_name}-jdoc.java" )
endforeach ( )
# g e n e r a t e j a v a d o c f i l e s
file ( GLOB_RECURSE refman_rst_headers "${CMAKE_CURRENT_SOURCE_DIR}/../*.rst" )
set ( java_documented_headers_deps ${ handwrittren_java_sources } ${ generated_java_sources } ${ java_hdr_deps } ${ refman_rst_headers }
" $ { G E N _ J A V A D O C } " " $ { R S T _ P A R S E R } " " $ { G E N _ J A V A } " " $ { H D R _ P A R S E R } " )
# T O D O : p a s s l i s t o f m o d u l e s
add_custom_command (
O U T P U T $ { d o c u m e n t e d _ j a v a _ f i l e s }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } " $ { G E N _ J A V A D O C } " " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / j a v a " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " 2 > " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g e t _ j a v a d o c _ e r r o r s . l o g "
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S $ { u n d o c u m e n t e d _ j a v a _ f i l e s }
D E P E N D S " $ { G E N _ J A V A D O C } "
D E P E N D S " $ { R S T _ P A R S E R } "
D E P E N D S $ { r e f m a n _ r s t _ h e a d e r s }
D E P E N D S $ { j a v a _ d o c u m e n t e d _ h e a d e r s _ d e p s }
)
# c o p y g e n e r a t e d j a v a f i l e s t o t h e f i n a l l o c a t i o n
set ( JAVA_OUTPUT_DIR "src/org/opencv" )
set ( java_files )
# 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 } )
get_filename_component ( java_file_name "${java_file}" NAME )
string ( REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}" )
@ -141,25 +127,24 @@ foreach(java_file ${documented_java_files})
add_custom_command (
O U T P U T " $ { C M A K E _ B I N A R Y _ D I R } / $ { J A V A _ O U T P U T _ D I R } / $ { j a v a _ f i l e _ n a m e } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y " $ { j a v a _ f i l e } " " $ { C M A K E _ B I N A R Y _ D I R } / $ { J A V A _ O U T P U T _ D I R } / $ { j a v a _ f i l e _ n a m e } "
D E P E N D S " $ { j a v a _ f i l e } "
M A I N _ D E P E N D E N C Y " $ { j a v a _ f i l e } "
D E P E N D S $ { j a v a _ d o c u m e n t e d _ h e a d e r s _ d e p s }
C O M M E N T " G e n e r a t i n g $ { J A V A _ O U T P U T _ D I R } / $ { j a v a _ f i l e _ n a m e } "
)
list ( APPEND java_files "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" )
if ( ANDROID )
get_filename_component ( install_subdir "${java_file_name}" PATH )
install ( FILES "${CMAKE_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${ JAVA_OUTPUT_DIR } / ${ install_subdir } COMPONENT main )
endif ( )
endforeach ( )
# c u s t o m t a r g e t f o r j a v a A P I
set ( api_target ${ target } _api )
add_custom_target ( ${ api_target } DEPENDS ${ java_files } )
set ( api_target ${ the_module } _api )
add_custom_target ( ${ api_target } DEPENDS ${ java_files } ${ documented_java_files } ${ java_documented_headers_deps } )
# a d d o p e n c v _ j a v a l i b r a r y
add_library ( ${ target } SHARED ${ handwrittren_h_sources } ${ handwrittren_cpp_sources } ${ generated_cpp_sources } )
add_library ( ${ the_module } SHARED ${ handwrittren_h_sources } ${ handwrittren_cpp_sources } ${ generated_cpp_sources } )
if ( BUILD_FAT_JAVA_LIB )
set ( __deps ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_MODULES_BUILD } )
list ( REMOVE_ITEM __deps ${ the_module } )
@ -170,51 +155,51 @@ if(BUILD_FAT_JAVA_LIB)
list ( REMOVE_ITEM __deps ${ __extradeps } )
endif ( )
target_link_libraries ( ${ target } -Wl,-whole-archive ${ __deps } -Wl,-no-whole-archive ${ __extradeps } ${ OPENCV_LINKER_LIBS } )
target_link_libraries ( ${ the_module } -Wl,-whole-archive ${ __deps } -Wl,-no-whole-archive ${ __extradeps } ${ OPENCV_LINKER_LIBS } )
else ( )
target_link_libraries ( ${ target } ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_LINKER_LIBS } )
target_link_libraries ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_LINKER_LIBS } )
endif ( )
add_dependencies ( ${ target } ${ api_target } )
add_dependencies ( ${ the_module } ${ api_target } )
# A d d i t i o n a l t a r g e t p r o p e r t i e s
set_target_properties ( ${ target } PROPERTIES
O U T P U T _ N A M E " $ { t a r g e t } "
set_target_properties ( ${ the_module } PROPERTIES
O U T P U T _ N A M E " $ { t h e _ m o d u l e } "
A R C H I V E _ O U T P U T _ D I R E C T O R Y $ { L I B R A R Y _ O U T P U T _ P A T H }
R U N T I M E _ O U T P U T _ D I R E C T O R Y $ { E X E C U T A B L E _ O U T P U T _ P A T H }
I N S T A L L _ N A M E _ D I R $ { O P E N C V _ L I B _ I N S T A L L _ P A T H }
L I N K _ I N T E R F A C E _ L I B R A R I E S " "
)
install ( TARGETS ${ target } LIBRARY DESTINATION ${ OPENCV_LIB_INSTALL_PATH } COMPONENT main )
install ( TARGETS ${ the_module } LIBRARY DESTINATION ${ OPENCV_LIB_INSTALL_PATH } COMPONENT main )
if ( ANDROID )
target_link_libraries ( ${ target } jnigraphics )
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
# f o r c e s t r i p l i b r a r y a f t e r b u i l d c o m m a n d
# b e c a u s e s a m p l e s a n d t e s t s w i l l m a k e a c o p y o f l i b r a r y b e f o r e i n s t a l l
# f o r c e s t r i p l i b r a r y a f t e r t h e b u i l d c o m m a n d
# b e c a u s e s a m p l e s a n d t e s t s w i l l m a k e a c o p y o f t h e l i b r a r y b e f o r e i n s t a l l
get_target_property ( __opencv_java_location ${ the_module } LOCATION )
add_custom_command (
T A R G E T $ { t a r g e t }
P O S T _ B U I L D
C O M M A N D $ { C M A K E _ S T R I P } - - s t r i p - u n n e e d e d " $ { L I B R A R Y _ O U T P U T _ P A T H } / l i b $ { t a r g e t } . s o "
T A R G E T $ { t h e _ m o d u l e } P O S T _ B U I L D
C O M M A N D $ { C M A K E _ S T R I P } - - s t r i p - u n n e e d e d " $ { _ _ o p e n c v _ j a v a _ l o c a t i o n } "
)
set ( lib_proj_files "" )
# l i b r a r y p r o j e c t b l a n k
file ( GLOB_RECURSE android_lib_project_files "${CMAKE_CURRENT_SOURCE_DIR}/android/*" )
foreach ( file ${ android_lib_project_files } )
if ( NOT file MATCHES "\\.svn" )
file ( RELATIVE_PATH file_rel "${CMAKE_CURRENT_SOURCE_DIR}/android/" "${file} " )
# m a n i f e s t , j n i , E c l i p s e p r o j e c t
file ( GLOB_RECURSE android_lib_project_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/android/" "${CMAKE_CURRENT_SOURCE_DIR}/android/*" )
foreach ( f ${ android_lib_project_files } )
if ( NOT f MATCHES "\\.svn ")
add_custom_command (
O U T P U T " $ { C M A K E _ B I N A R Y _ D I R } / $ { f i l e _ r e l } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y " $ { f i l e } " " $ { C M A K E _ B I N A R Y _ D I R } / $ { f i l e _ r e l } "
D E P E N D S " $ { f i l e } "
C O M M E N T " G e n e r a t i n g $ { f i l e _ r e l } "
O U T P U T " $ { C M A K E _ B I N A R Y _ D I R } / $ { f } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a n d r o i d / $ { f } " " $ { C M A K E _ B I N A R Y _ D I R } / $ { f } "
D E P E N D S " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a n d r o i d / $ { f } "
C O M M E N T " G e n e r a t i n g $ { f } "
)
list ( APPEND lib_proj_files "${CMAKE_BINARY_DIR}/${file_rel}" )
if ( NOT file_rel MATCHES "jni/.+" )
install ( FILES "${CMAKE_BINARY_DIR}/${file_rel}" DESTINATION . COMPONENT main )
list ( APPEND lib_proj_files "${CMAKE_BINARY_DIR}/${f}" )
if ( NOT f MATCHES "jni/.+" )
install ( FILES "${CMAKE_BINARY_DIR}/${f}" DESTINATION . COMPONENT main )
endif ( )
endif ( )
endforeach ( )
@ -226,30 +211,52 @@ if(ANDROID)
O U T P U T " $ { C M A K E _ B I N A R Y _ D I R } / j n i / $ { j n i _ f i l e _ n a m e } "
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y " $ { j n i _ f i l e } " " $ { C M A K E _ B I N A R Y _ D I R } / j n i / $ { j n i _ f i l e _ n a m e } "
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 " $ { C M A K E _ B I N A R Y _ D I R } / j n i / $ { j n i _ f i l e _ n a m e } "
D E P E N D S " $ { j n i _ f i l e } "
D E P E N D S " $ { j n i _ f i l e } " $ { j a v a _ h d r _ d e p s }
C O M M E N T " G e n e r a t i n g j n i / $ { j n i _ f i l e _ n a m e } "
)
list ( APPEND lib_proj_files "${CMAKE_BINARY_DIR}/jni/${jni_file_name}" )
endforeach ( )
endforeach ( )
# 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
set ( lib_target ${ target } _android_library )
add_custom_target ( ${ lib_target }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y " $ { C M A K E _ B I N A R Y _ D I R } / r e s "
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y " $ { C M A K E _ B I N A R Y _ D I R } / g e n "
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 "${CMAKE_BINARY_DIR}/" )
android_get_compatible_target ( lib_target_sdk_target 8 )
add_custom_command (
O U T P U T $ { l i b _ t a r g e t _ f i l e s }
C O M M A N D $ { C M A K E _ C O M M A N D } - E r e m o v e $ { l i b _ t a r g e t _ f i l e s }
C O M M A N D $ { A N D R O I D _ E X E C U T A B L E } - - s i l e n t c r e a t e l i b - p r o j e c t - - p a t h \ " $ { C M A K E _ B I N A R Y _ D I R } \ " - - t a r g e t \ " $ { l i b _ t a r g e t _ s d k _ t a r g e t } \ " - - n a m e O p e n C V - - p a c k a g e o r g . o p e n c v 2 > \ " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c r e a t e _ l i b _ p r o j e c t . l o g \ "
M A I N _ D E P E N D E N C Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { A N D R O I D _ M A N I F E S T _ F I L E } "
D E P E N D S $ { l i b _ p r o j _ f i l e s }
C O M M E N T " G e n e r a t i n g O p e n C V A n d r o i d l i b r a r y p r o j e c t . S D K t a r g e t : $ { l i b _ t a r g e t _ s d k _ t a r g e t } "
)
install ( FILES "${CMAKE_BINARY_DIR}/${ANDROID_PROJECT_PROPERTIES_FILE}" DESTINATION . COMPONENT main )
if ( ANT_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13 )
# b u i l d t h e l i b r a r y p r o j e c t
# n o r m a l l y w e s h o u l d d o t h i s a f t e r a n a t i v e p a r t , b u t f o r a l i b r a r y p r o j e c t w e c a n b u i l d t h e j a v a p a r t f i r s t
add_custom_command (
O U T P U T " $ { C M A K E _ B I N A R Y _ D I R } / b i n / c l a s s e s . j a 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 d e b u g
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } "
D E P E N D S $ { l i b _ p r o j _ f i l e s } $ { l i b _ t a r g e t _ f i l e s } $ { j a v a _ f i l e s }
C O M M E N T " B u i l d i n g O p e n C V A n d r o i d l i b r a r y p r o j e c t "
)
install ( FILES "${CMAKE_BINARY_DIR}/bin/classes.jar" DESTINATION bin COMPONENT main )
list ( APPEND lib_target_files "${CMAKE_BINARY_DIR}/bin/classes.jar" )
endif ( )
add_custom_target ( ${ lib_target }
S O U R C E S $ { l i b _ p r o j _ f i l e s } $ { l i b _ t a r g e t _ f i l e s }
)
if ( ANT_EXECUTABLE AND ANDROID_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13 )
add_custom_command ( TARGET ${ target }
C O M M A N D $ { A N D R O I D _ E X E C U T A B L E } u p d a t e l i b - p r o j e c t - - t a r g e t " $ { A N D R O I D _ S D K _ T A R G E T } " - - p a t h " $ { C M A K E _ B I N A R Y _ D I R } "
C O M M A N D $ { A N T _ E X E C U T A B L E } d e b u g
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } "
D E P E N D S $ { l i b _ t a r g e t }
)
endif ( )
add_dependencies ( ${ lib_target } ${ api_target } )
add_dependencies ( ${ target } ${ lib_target } )
add_dependencies ( ${ lib_target } ${ api_target } )
add_dependencies ( ${ the_module } ${ lib_target } )
endif ( )
endif ( ANDROID )
# a n d r o i d t e s t p r o j e c t
@ -257,9 +264,10 @@ ocv_check_dependencies(${OPENCV_MODULE_${the_module}_OPT_DEPS})
if ( BUILD_TESTS AND OCV_DEPENDENCIES_FOUND )
add_android_project ( opencv_test_java "${CMAKE_CURRENT_SOURCE_DIR}/android_test" )
add_custom_command (
if ( PYTHON_EXECUTABLE )
add_custom_command (
T A R G E T o p e n c v _ t e s t _ j a v a _ a n d r o i d _ p r o j e c t P O S T _ B U I L D
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { C H E C K _ T E S T _ C O V E R A G E } " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / a n d r o i d _ t e s t / s r c " " $ { C M A K E _ B I N A R Y _ D I R } / s r c " > " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / t e s t s _ c o v e r a g e . l o g "
)
endif ( )
endif ( )