2011-06-23 17:51:51 +02:00
# ----------------------------------------------------------------------------
# CMake file for java support
# ----------------------------------------------------------------------------
2012-03-25 21:57:58 +02:00
if ( NOT ANDROID OR NOT PYTHON_EXECUTABLE OR ANDROID_NATIVE_API_LEVEL LESS 8 )
2012-02-03 12:26:49 +01:00
ocv_module_disable ( java )
endif ( )
2011-07-24 22:44:20 +02:00
2012-02-03 12:26:49 +01:00
set ( the_description "The java bindings" )
2012-07-05 09:58:40 +02:00
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 )
2012-06-21 13:44:31 +02:00
ocv_module_include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp" )
2011-06-23 17:51:51 +02:00
2012-03-25 21:57:58 +02:00
# get list of modules to wrap
2012-02-20 12:50:43 +01:00
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 } )
list ( REMOVE_ITEM OPENCV_JAVA_MODULES ${ module } )
endif ( )
endforeach ( )
2011-06-23 17:51:51 +02:00
2012-06-21 13:44:31 +02:00
set ( GEN_JAVA "${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_java.py" )
2012-02-20 12:50:43 +01:00
set ( HDR_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/../python/src2/hdr_parser.py" )
2012-06-21 13:44:31 +02:00
set ( GEN_JAVADOC "${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_javadoc.py" )
set ( RST_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/generator/rst_parser.py" )
2011-06-23 17:51:51 +02:00
2012-03-25 21:57:58 +02:00
# add dependencies to cmake (we should rerun cmake if any of these scripts is modified)
2012-03-27 18:05:52 +02:00
configure_file ( "${GEN_JAVA}" "${OpenCV_BINARY_DIR}/junk/gen_java.junk" COPYONLY )
configure_file ( "${HDR_PARSER}" "${OpenCV_BINARY_DIR}/junk/hdr_parser.junk" COPYONLY )
2012-03-25 21:57:58 +02:00
set ( java_hdr_deps "" )
set ( generated_cpp_sources "" )
set ( generated_java_sources "" )
2011-07-22 15:10:50 +02:00
# setup raw java and cpp files generation (without javadoc and at temporary location)
2011-06-23 17:51:51 +02:00
foreach ( module ${ OPENCV_JAVA_MODULES } )
2012-02-20 12:50:43 +01:00
# get list of module headers
2012-06-21 13:44:31 +02:00
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/generator/config/${module}.filelist" )
file ( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/generator/config/${module}.filelist" module_headers )
2012-03-25 21:57:58 +02:00
ocv_list_add_prefix ( module_headers "${OPENCV_MODULE_opencv_${module}_LOCATION}/" )
2012-02-20 12:50:43 +01:00
else ( )
2012-03-25 21:57:58 +02:00
set ( module_headers "${OPENCV_MODULE_opencv_${module}_HEADERS}" )
2012-02-20 12:50:43 +01:00
endif ( )
2012-03-25 21:57:58 +02:00
# C headers must go first
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 )
2012-02-20 12:50:43 +01:00
# add dependencies to cmake (we should rerun cmake if any of these headers is modified)
2012-03-25 21:57:58 +02:00
foreach ( header ${ module_headers } )
2012-02-20 12:50:43 +01:00
get_filename_component ( header_name "${header}" NAME_WE )
2012-03-27 18:05:52 +02:00
configure_file ( "${header}" "${OpenCV_BINARY_DIR}/junk/${header_name}.junk" COPYONLY )
2012-02-20 12:50:43 +01:00
endforeach ( )
# first run (to get list of generated files)
2012-04-30 16:33:52 +02:00
if ( module_headers )
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_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}/" )
# second 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 } )
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} )
endif ( )
2011-06-23 17:51:51 +02:00
endforeach ( )
2012-03-25 21:57:58 +02:00
# get handwritten files used for wrappers generation
2012-06-21 13:44:31 +02:00
file ( GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp/*.hpp" )
file ( GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp/*.cpp" )
file ( GLOB handwrittren_java_sources "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/java/*.java" )
file ( GLOB handwrittren_aidl_sources "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/java/*.aidl" )
2012-02-20 12:50:43 +01:00
2012-03-25 21:57:58 +02:00
# remove handwritten java files for disabled modules
2012-02-20 12:50:43 +01:00
foreach ( jfile ${ handwrittren_java_sources } )
string ( REGEX REPLACE "^.*/([^+]+)\\+.*\\.java$" "\\1" jmodname "${jfile}" )
if ( DEFINED HAVE_opencv_ ${ jmodname } AND NOT HAVE_opencv_ ${ jmodname } )
list ( REMOVE_ITEM handwrittren_java_sources "${jfile}" )
endif ( )
endforeach ( )
2011-06-23 17:51:51 +02:00
2012-03-25 21:57:58 +02:00
# remove VideoCapture wrapper if highgui is disabled
if ( NOT HAVE_opencv_highgui )
2012-06-21 13:44:31 +02:00
list ( REMOVE_ITEM handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp/VideoCapture.cpp" )
2012-03-25 21:57:58 +02:00
endif ( )
2011-06-23 17:51:51 +02:00
2012-03-25 21:57:58 +02:00
# create list of javadoc documented files
unset ( documented_java_files )
2011-07-22 15:10:50 +02:00
foreach ( java_file ${ handwrittren_java_sources } ${ generated_java_sources } )
2012-02-20 12:50:43 +01:00
get_filename_component ( java_file_name "${java_file}" NAME_WE )
2012-03-25 21:57:58 +02:00
list ( APPEND documented_java_files "${CMAKE_CURRENT_BINARY_DIR}/${java_file_name}-jdoc.java" )
2011-07-22 15:10:50 +02:00
endforeach ( )
# generate javadoc files
2011-07-24 22:44:20 +02:00
file ( GLOB_RECURSE refman_rst_headers "${CMAKE_CURRENT_SOURCE_DIR}/../*.rst" )
2012-03-25 21:57:58 +02:00
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 } " )
#TODO: pass list of modules
2011-07-22 15:10:50 +02:00
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 }
2012-06-21 13:44:31 +02:00
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 } / g e n e r a t o 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 "
2011-07-22 15:10:50 +02:00
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 }
2012-03-25 21:57:58 +02:00
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 }
2011-07-22 15:10:50 +02:00
)
# copy generated java files to the final location
2012-02-20 12:50:43 +01:00
set ( JAVA_OUTPUT_DIR "src/org/opencv" )
2012-06-27 08:22:26 +02:00
set ( JAVA_INSTALL_ROOT "sdk/java" )
set ( JNI_INSTALL_ROOT "sdk/native" )
2011-07-22 15:10:50 +02:00
2012-03-25 21:57:58 +02:00
# copy each documented header to the final destination
set ( java_files "" )
2012-06-21 16:50:05 +02:00
foreach ( java_file ${ documented_java_files } ${ handwrittren_aidl_sources } )
2012-02-20 12:50:43 +01:00
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}" )
2011-06-23 17:51:51 +02:00
2012-02-20 12:50:43 +01:00
add_custom_command (
2012-03-27 18:05:52 +02:00
O U T P U T " $ { O p e n C V _ 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 } " " $ { O p e n C V _ 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 } "
2012-03-25 21:57:58 +02:00
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 }
2011-07-24 22:44:20 +02:00
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 } "
2011-07-22 15:10:50 +02:00
)
2012-03-27 18:05:52 +02:00
list ( APPEND java_files "${OpenCV_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" )
2012-03-25 21:57:58 +02:00
2012-02-20 12:50:43 +01:00
if ( ANDROID )
get_filename_component ( install_subdir "${java_file_name}" PATH )
2012-06-27 08:22:26 +02:00
install ( FILES "${OpenCV_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${ JAVA_INSTALL_ROOT } / ${ JAVA_OUTPUT_DIR } / ${ install_subdir } COMPONENT main )
2012-02-20 12:50:43 +01:00
endif ( )
2011-07-22 15:10:50 +02:00
endforeach ( )
2011-07-24 22:44:20 +02:00
# custom target for java API
2012-03-25 21:57:58 +02:00
set ( api_target ${ the_module } _api )
add_custom_target ( ${ api_target } DEPENDS ${ java_files } ${ documented_java_files } ${ java_documented_headers_deps } )
2011-07-22 15:10:50 +02:00
2011-07-24 22:44:20 +02:00
# add opencv_java library
2012-03-25 21:57:58 +02:00
add_library ( ${ the_module } SHARED ${ handwrittren_h_sources } ${ handwrittren_cpp_sources } ${ generated_cpp_sources } )
2012-03-23 18:03:05 +01:00
if ( BUILD_FAT_JAVA_LIB )
set ( __deps ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_MODULES_BUILD } )
2012-06-29 10:11:20 +02:00
list ( REMOVE_ITEM __deps ${ the_module } opencv_ts )
2012-03-23 18:03:05 +01:00
ocv_list_unique ( __deps )
set ( __extradeps ${ __deps } )
ocv_list_filterout ( __extradeps "^opencv_" )
if ( __extradeps )
list ( REMOVE_ITEM __deps ${ __extradeps } )
endif ( )
2012-03-25 21:57:58 +02:00
target_link_libraries ( ${ the_module } -Wl,-whole-archive ${ __deps } -Wl,-no-whole-archive ${ __extradeps } ${ OPENCV_LINKER_LIBS } )
2012-03-23 18:03:05 +01:00
else ( )
2012-03-25 21:57:58 +02:00
target_link_libraries ( ${ the_module } ${ OPENCV_MODULE_${the_module } _DEPS} ${ OPENCV_LINKER_LIBS } )
2012-03-23 18:03:05 +01:00
endif ( )
2012-03-25 21:57:58 +02:00
add_dependencies ( ${ the_module } ${ api_target } )
2011-07-04 10:18:02 +02:00
2011-07-22 15:10:50 +02:00
# Additional target properties
2012-03-25 21:57:58 +02:00
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 } "
2011-07-22 15:10:50 +02:00
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 }
2012-03-23 18:03:05 +01:00
L I N K _ I N T E R F A C E _ L I B R A R I E S " "
2011-07-22 15:10:50 +02:00
)
2012-03-25 21:57:58 +02:00
install ( TARGETS ${ the_module } LIBRARY DESTINATION ${ OPENCV_LIB_INSTALL_PATH } COMPONENT main )
2011-07-22 15:10:50 +02:00
2011-06-23 17:51:51 +02:00
if ( ANDROID )
2012-03-25 21:57:58 +02:00
target_link_libraries ( ${ the_module } jnigraphics ) # for Mat <=> Bitmap converters
2011-07-04 10:18:02 +02:00
2012-03-25 21:57:58 +02:00
# force strip library after the build command
# because samples and tests will make a copy of the library before install
get_target_property ( __opencv_java_location ${ the_module } LOCATION )
2012-08-14 10:03:05 +02:00
# Turn off stripping in debug build
if ( NOT ( CMAKE_BUILD_TYPE MATCHES "debug" ) )
add_custom_command ( TARGET ${ the_module } POST_BUILD COMMAND ${ CMAKE_STRIP } --strip-unneeded "${__opencv_java_location}" )
endif ( )
2011-07-22 15:10:50 +02:00
2012-02-20 12:50:43 +01:00
set ( lib_proj_files "" )
2012-03-25 21:57:58 +02:00
# manifest, jni, Eclipse project
2012-06-21 13:44:31 +02:00
file ( GLOB_RECURSE android_lib_project_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/" "${CMAKE_CURRENT_SOURCE_DIR}/android_lib/*" )
2012-04-30 16:33:52 +02:00
list ( REMOVE_ITEM android_lib_project_files "${ANDROID_MANIFEST_FILE}" )
2012-03-25 21:57:58 +02:00
foreach ( f ${ android_lib_project_files } )
if ( NOT f MATCHES "\\.svn" )
2012-02-20 12:50:43 +01:00
add_custom_command (
2012-03-27 18:05:52 +02:00
O U T P U T " $ { O p e n C V _ B I N A R Y _ D I R } / $ { f } "
2012-06-21 13:44:31 +02:00
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 _ l i b / $ { f } " " $ { O p e n C V _ B I N A R Y _ D I R } / $ { f } "
M A I N _ D E P E N D E N C 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 _ l i b / $ { f } "
2012-03-25 21:57:58 +02:00
C O M M E N T " G e n e r a t i n g $ { f } "
2011-07-22 15:10:50 +02:00
)
2011-07-22 16:11:16 +02:00
2012-03-27 18:05:52 +02:00
list ( APPEND lib_proj_files "${OpenCV_BINARY_DIR}/${f}" )
2012-03-25 21:57:58 +02:00
if ( NOT f MATCHES "jni/.+" )
2012-06-27 08:22:26 +02:00
get_filename_component ( install_subdir "${f}" PATH )
install ( FILES "${OpenCV_BINARY_DIR}/${f}" DESTINATION "${JAVA_INSTALL_ROOT}/${install_subdir}" COMPONENT main )
2012-02-20 12:50:43 +01:00
endif ( )
endif ( )
endforeach ( )
2011-07-22 15:10:50 +02:00
2012-02-20 12:50:43 +01:00
# library project jni sources
foreach ( jni_file ${ handwrittren_cpp_sources } ${ handwrittren_h_sources } ${ generated_cpp_sources } )
get_filename_component ( jni_file_name "${jni_file}" NAME )
add_custom_command (
2012-03-27 18:05:52 +02:00
O U T P U T " $ { O p e n C V _ 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 } " " $ { O p e n C V _ B I N A R Y _ D I R } / j n i / $ { j n i _ f i l e _ n a m e } "
2012-03-25 21:57:58 +02:00
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 }
2011-07-22 15:10:50 +02:00
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 } "
2012-02-20 12:50:43 +01:00
)
2012-03-27 18:05:52 +02:00
list ( APPEND lib_proj_files "${OpenCV_BINARY_DIR}/jni/${jni_file_name}" )
2012-03-25 21:57:58 +02:00
endforeach ( )
2012-02-20 12:50:43 +01:00
# create Android library project in build folder
2012-03-25 21:57:58 +02:00
if ( ANDROID_EXECUTABLE )
set ( lib_target ${ the_module } _android_library )
set ( lib_target_files ${ ANDROID_LIB_PROJECT_FILES } )
2012-03-27 18:05:52 +02:00
ocv_list_add_prefix ( lib_target_files "${OpenCV_BINARY_DIR}/" )
2012-03-25 21:57:58 +02:00
2012-03-27 18:05:52 +02:00
android_get_compatible_target ( lib_target_sdk_target ${ ANDROID_NATIVE_API_LEVEL } ${ ANDROID_SDK_TARGET } )
2012-03-25 21:57:58 +02:00
add_custom_command (
2012-04-30 16:33:52 +02:00
O U T P U T $ { l i b _ t a r g e t _ f i l e s } " $ { O p e n C V _ 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 } "
2012-03-25 21:57:58 +02:00
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 }
2012-06-21 13:44:31 +02:00
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 _ l i b / $ { A N D R O I D _ M A N I F E S T _ F I L E } " " $ { O p e n C V _ 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 } "
2012-03-27 18:05:52 +02:00
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 \ " $ { O p e n C V _ 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 \ "
2012-06-21 13:44:31 +02:00
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 _ l i b / $ { A N D R O I D _ M A N I F E S T _ F I L E } " " $ { O p e n C V _ 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 } "
M A I N _ D E P E N D E N C 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 _ l i b / $ { A N D R O I D _ M A N I F E S T _ F I L E } "
2011-07-24 22:44:20 +02:00
D E P E N D S $ { l i b _ p r o j _ f i l e s }
2012-03-25 21:57:58 +02:00
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 } "
)
2012-06-27 08:22:26 +02:00
install ( FILES "${OpenCV_BINARY_DIR}/${ANDROID_PROJECT_PROPERTIES_FILE}" DESTINATION ${ JAVA_INSTALL_ROOT } COMPONENT main )
install ( FILES "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" DESTINATION ${ JAVA_INSTALL_ROOT } COMPONENT main )
# creating empty 'gen' and 'res' folders
install ( CODE "MAKE_DIRECTORY(\" \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sdk/java/gen\")" COMPONENT main )
install ( CODE "MAKE_DIRECTORY(\" \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sdk/java/res\")" COMPONENT main )
2012-03-25 21:57:58 +02:00
if ( ANT_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13 )
# build the library project
# normally we should do this after a native part, but for a library project we can build the java part first
add_custom_command (
2012-06-28 13:06:31 +02:00
O U T P U T " $ { O p e n C V _ B I N A R Y _ D I R } / b i n / c l a s s e s . j a r " " $ { O p e n C V _ B I N A R Y _ D I R } / b i n / . c l a s s e s . j a r . d e p h e l p e r "
2012-03-25 21:57:58 +02:00
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
2012-06-28 13:06:31 +02:00
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 / . c l a s s e s . j a r . d e p h e l p e r " # can not rely on classes.jar because different versions of SDK update timestamp at different times
2012-03-27 18:05:52 +02:00
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 } "
2012-03-25 21:57:58 +02:00
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 "
)
2012-06-21 16:50:05 +02:00
#install(FILES "${OpenCV_BINARY_DIR}/bin/classes.jar" "${OpenCV_BINARY_DIR}/bin/jarlist.cache" "${OpenCV_BINARY_DIR}/bin/build.prop" DESTINATION bin COMPONENT main)
#install(DIRECTORY "${OpenCV_BINARY_DIR}/bin/res" "${OpenCV_BINARY_DIR}/bin/classes" DESTINATION bin COMPONENT main)
2012-03-27 18:05:52 +02:00
list ( APPEND lib_target_files "${OpenCV_BINARY_DIR}/bin/classes.jar" )
2012-03-25 21:57:58 +02:00
endif ( )
2012-04-30 16:33:52 +02:00
add_custom_target ( ${ lib_target } SOURCES ${ lib_proj_files } ${ lib_target_files } "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" )
2011-06-30 16:35:35 +02:00
2012-03-25 21:57:58 +02:00
add_dependencies ( ${ lib_target } ${ api_target } )
add_dependencies ( ${ the_module } ${ lib_target } )
endif ( )
2011-07-24 22:44:20 +02:00
endif ( ANDROID )
2011-06-30 16:35:35 +02:00
2011-07-24 22:44:20 +02:00
#android test project
2012-03-27 18:05:52 +02:00
if ( ANDROID AND BUILD_TESTS )
add_subdirectory ( android_test )
2011-07-24 22:44:20 +02:00
endif ( )