5
project(opencv_test_java)
7
set(opencv_test_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.build")
8
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR})
9
set(test_common_dir "${CMAKE_CURRENT_SOURCE_DIR}/../common_test")
11
set(opencv_test_java_file_deps "")
13
# make sure the build directory exists
14
file(MAKE_DIRECTORY "${opencv_test_java_bin_dir}")
16
# 1. gather and copy common test files (resources, utils, etc.)
17
copy_common_tests(test_common_dir opencv_test_java_bin_dir opencv_test_java_file_deps)
19
# 2. gather and copy tests from each module
20
copy_modules_tests(OPENCV_JAVA_MODULES opencv_test_java_bin_dir opencv_test_java_file_deps)
22
# 3. gather and copy specific files for pure java
23
file(GLOB_RECURSE test_files RELATIVE "${test_dir}" "${test_dir}/src/*")
24
file(GLOB_RECURSE test_lib_files RELATIVE "${test_dir}" "${test_dir}/lib/*.jar")
25
foreach(f ${test_files} ${test_lib_files})
26
add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/${f}"
27
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}"
28
DEPENDS "${test_dir}/${f}"
29
COMMENT "Copying ${f}"
31
list(APPEND opencv_test_java_file_deps "${test_dir}/${f}" "${opencv_test_java_bin_dir}/${f}")
34
# Copy the OpenCV jar after it has been generated.
35
add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/bin/${JAR_NAME}"
36
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${JAR_FILE}" "${opencv_test_java_bin_dir}/bin/${JAR_NAME}"
38
COMMENT "Copying the OpenCV jar"
41
add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/build.xml"
42
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${opencv_test_java_bin_dir}/build.xml"
43
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build.xml"
44
COMMENT "Copying build.xml"
47
add_custom_command(OUTPUT "${opencv_test_java_bin_dir}/build/jar/opencv-test.jar"
48
COMMAND "${ANT_EXECUTABLE}" build
49
WORKING_DIRECTORY "${opencv_test_java_bin_dir}"
50
DEPENDS ${opencv_test_java_file_deps} "${opencv_test_java_bin_dir}/build.xml" "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${JAR_FILE}" "${opencv_test_java_bin_dir}/bin/${JAR_NAME}"
51
COMMENT "Build Java tests"
54
# Not add_custom_command because generator expressions aren't supported in
55
# OUTPUT file names, and we need to generate different files for different
57
add_custom_target(${PROJECT_NAME}_properties
58
COMMAND "${CMAKE_COMMAND}" -E echo "opencv.lib.path = $<TARGET_FILE_DIR:${the_module}>"
59
> "${opencv_test_java_bin_dir}/ant-$<CONFIGURATION>.properties"
63
add_custom_target(${PROJECT_NAME} ALL
64
DEPENDS ${the_module} ${PROJECT_NAME}_properties
65
SOURCES "${opencv_test_java_bin_dir}/build/jar/opencv-test.jar"
68
if(ENABLE_SOLUTION_FOLDERS)
69
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "tests accuracy")