mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.7 KiB
72 lines
3.7 KiB
10 years ago
|
if(NOT ANT_EXECUTABLE OR NOT ANDROID_EXECUTABLE OR NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
|
||
13 years ago
|
return()
|
||
|
endif()
|
||
|
|
||
|
project(opencv_test_java)
|
||
|
|
||
|
set(opencv_test_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.build")
|
||
10 years ago
|
set(test_dir "${CMAKE_CURRENT_SOURCE_DIR}")
|
||
|
set(test_common_dir "${CMAKE_CURRENT_SOURCE_DIR}/../common_test")
|
||
13 years ago
|
|
||
|
set(opencv_test_java_file_deps "")
|
||
10 years ago
|
|
||
|
# 1. gather and copy common test files (resources, utils, etc.)
|
||
|
copy_common_tests(test_common_dir opencv_test_java_bin_dir opencv_test_java_file_deps)
|
||
|
|
||
|
# 2. gather and copy tests from each module
|
||
|
copy_modules_tests(OPENCV_JAVA_MODULES opencv_test_java_bin_dir opencv_test_java_file_deps)
|
||
|
|
||
|
# 3. gather and copy specific files for Android
|
||
|
file(GLOB_RECURSE test_files RELATIVE "${test_dir}" "${test_dir}/res/*" "${test_dir}/src/*")
|
||
|
foreach(f ${test_files} ${ANDROID_MANIFEST_FILE} ".classpath" ".project")
|
||
13 years ago
|
add_custom_command(
|
||
|
OUTPUT "${opencv_test_java_bin_dir}/${f}"
|
||
9 years ago
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}"
|
||
10 years ago
|
MAIN_DEPENDENCY "${test_dir}/${f}"
|
||
13 years ago
|
COMMENT "Copying ${f}")
|
||
10 years ago
|
list(APPEND opencv_test_java_file_deps "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}")
|
||
13 years ago
|
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"
|
||
7 years ago
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:opencv_java>" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/$<TARGET_FILE_NAME:opencv_java>"
|
||
9 years ago
|
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
|
||
13 years ago
|
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}"
|
||
12 years ago
|
DEPENDS "${JAR_FILE}.dephelper" opencv_java
|
||
12 years ago
|
DEPENDS ${opencv_test_java_file_deps})
|
||
13 years ago
|
|
||
|
add_custom_target(${PROJECT_NAME} ALL SOURCES "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" )
|
||
12 years ago
|
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)
|
||
13 years ago
|
|
||
|
# put the final .apk to the OpenCV's bin folder
|
||
9 years ago
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" "${OpenCV_BINARY_DIR}/bin/${PROJECT_NAME}.apk")
|
||
13 years ago
|
|
||
|
add_dependencies(opencv_tests ${PROJECT_NAME})
|
||
|
|
||
11 years ago
|
if(PYTHON_DEFAULT_AVAILABLE)
|
||
13 years ago
|
set(CHECK_TEST_COVERAGE "${OPENCV_MODULE_opencv_java_LOCATION}/check-tests.py")
|
||
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||
11 years ago
|
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/src" "${OpenCV_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log"
|
||
13 years ago
|
)
|
||
|
endif()
|