2014-09-19 16:09:53 +08:00
|
|
|
# list of modules covered with tests
|
2014-09-19 17:10:14 +08:00
|
|
|
set(tested_modules opencv_calib3d opencv_core opencv_features2d opencv_highgui opencv_imgproc opencv_objdetect opencv_photo opencv_video)
|
2014-09-19 16:09:53 +08:00
|
|
|
|
|
|
|
# opencv_ml is broken
|
|
|
|
#list(APPEND tested_modules opencv_ml)
|
|
|
|
|
|
|
|
ocv_check_dependencies(opencv_java ${tested_modules})
|
2012-03-28 00:05:52 +08:00
|
|
|
|
|
|
|
if(NOT OCV_DEPENDENCIES_FOUND OR NOT ANT_EXECUTABLE OR NOT ANDROID_EXECUTABLE OR NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
project(opencv_test_java)
|
|
|
|
|
|
|
|
set(opencv_test_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.build")
|
|
|
|
|
|
|
|
# get project sources
|
|
|
|
file(GLOB_RECURSE opencv_test_java_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/res/*" "${CMAKE_CURRENT_SOURCE_DIR}/src/*")
|
|
|
|
ocv_list_filterout(opencv_test_java_files ".svn")
|
2014-09-08 23:21:32 +08:00
|
|
|
# opencv_ml is broken
|
|
|
|
ocv_list_filterout(opencv_test_java_files "/ml/")
|
2012-03-28 00:05:52 +08:00
|
|
|
|
|
|
|
# copy sources out from the build tree
|
|
|
|
set(opencv_test_java_file_deps "")
|
2013-04-05 12:50:08 +08:00
|
|
|
foreach(f ${opencv_test_java_files} ${ANDROID_MANIFEST_FILE} ".classpath" ".project")
|
2012-03-28 00:05:52 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${opencv_test_java_bin_dir}/${f}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${opencv_test_java_bin_dir}/${f}"
|
|
|
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${f}"
|
|
|
|
COMMENT "Copying ${f}")
|
|
|
|
list(APPEND opencv_test_java_file_deps "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${opencv_test_java_bin_dir}/${f}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# fix Android project
|
|
|
|
set(android_proj_target_files ${ANDROID_PROJECT_FILES})
|
|
|
|
ocv_list_add_prefix(android_proj_target_files "${opencv_test_java_bin_dir}/")
|
|
|
|
file(RELATIVE_PATH __dep "${opencv_test_java_bin_dir}" "${OpenCV_BINARY_DIR}")
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${android_proj_target_files}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove ${android_proj_target_files}
|
|
|
|
COMMAND ${ANDROID_EXECUTABLE} --silent update test-project --path "${opencv_test_java_bin_dir}" --main "${OpenCV_BINARY_DIR}"
|
|
|
|
COMMAND ${ANDROID_EXECUTABLE} --silent update project --path "${opencv_test_java_bin_dir}" --library "${__dep}"
|
|
|
|
MAIN_DEPENDENCY "${opencv_test_java_bin_dir}/${ANDROID_MANIFEST_FILE}"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}"
|
|
|
|
COMMENT "Updating Android Java API test project")
|
|
|
|
|
|
|
|
list(APPEND opencv_test_java_file_deps ${android_proj_target_files})
|
|
|
|
|
|
|
|
# build java part
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk"
|
2012-06-27 20:38:57 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}/libopencv_java.so" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/libopencv_java.so"
|
2012-03-28 00:05:52 +08:00
|
|
|
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E touch "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" # needed because ant does not update the timestamp of updated apk
|
|
|
|
WORKING_DIRECTORY "${opencv_test_java_bin_dir}"
|
|
|
|
MAIN_DEPENDENCY "${opencv_test_java_bin_dir}/${ANDROID_MANIFEST_FILE}"
|
2013-01-22 21:56:04 +08:00
|
|
|
DEPENDS "${JAR_FILE}.dephelper" opencv_java
|
2012-09-04 17:26:08 +08:00
|
|
|
DEPENDS ${opencv_test_java_file_deps})
|
2012-03-28 00:05:52 +08:00
|
|
|
|
|
|
|
add_custom_target(${PROJECT_NAME} ALL SOURCES "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" )
|
2012-09-04 17:26:08 +08:00
|
|
|
add_dependencies(${PROJECT_NAME} opencv_java ${__android_project_chain})
|
|
|
|
set(__android_project_chain ${PROJECT_NAME} CACHE INTERNAL "auxiliary variable used for Android progects chaining" FORCE)
|
2012-03-28 00:05:52 +08:00
|
|
|
|
|
|
|
# put the final .apk to the OpenCV's bin folder
|
|
|
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" "${OpenCV_BINARY_DIR}/bin/${PROJECT_NAME}.apk")
|
|
|
|
|
|
|
|
add_dependencies(opencv_tests ${PROJECT_NAME})
|
|
|
|
|
2014-06-30 04:45:24 +08:00
|
|
|
if(PYTHON_DEFAULT_AVAILABLE)
|
2012-03-28 05:27:27 +08:00
|
|
|
set(CHECK_TEST_COVERAGE "${OPENCV_MODULE_opencv_java_LOCATION}/check-tests.py")
|
|
|
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
2014-06-30 04:45:24 +08:00
|
|
|
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/src" "${OpenCV_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log"
|
2012-03-28 05:27:27 +08:00
|
|
|
)
|
|
|
|
endif()
|