Fixed Android tests and samples build

pull/13383/head
Andrey Kamaev 14 years ago
parent 6d549490fb
commit 65cb53aa1e
  1. 15
      modules/java/CMakeLists.txt
  2. 9
      samples/android/CMakeLists.txt

@ -138,8 +138,11 @@ endforeach()
#android test project
if(ANDROID AND BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS)
SET(test_dir "${CMAKE_CURRENT_SOURCE_DIR}/android_test")
SET(test_target OpenCV_JavaAPI_Tests)
file(COPY android_test DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN ".svn" EXCLUDE)
SET(test_dir "${CMAKE_CURRENT_BINARY_DIR}/android_test")
SET(test_name opencv_test_java)
SET(test_target ${test_name}_android)
add_custom_target(${test_target} ALL)
add_dependencies(${test_target} opencv_java opencv_java_api)
@ -151,14 +154,12 @@ if(ANDROID AND BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS)
WORKING_DIRECTORY ${test_dir}
COMMAND ${CMAKE_COMMAND} -E remove -f "${test_dir}/default.properties"
COMMAND ${CMAKE_COMMAND} -E touch "${test_dir}/default.properties"
COMMAND ${ANDROID_EXECUTABLE} update project --name "${test_target}" --target android-8 --library "${OPENCV_REFERENCE_PATH}" --path .
COMMAND ${ANDROID_EXECUTABLE} update project --name "${test_name}" --target android-8 --library "${OPENCV_REFERENCE_PATH}" --path .
COMMAND ${ANT_EXECUTABLE} debug
COMMAND ${CMAKE_COMMAND} -E copy "${test_dir}/bin/${test_target}-debug.apk" "${CMAKE_BINARY_DIR}/bin/${test_target}-debug.apk"
COMMAND ${CMAKE_COMMAND} -E copy "${test_dir}/bin/${test_name}-debug.apk" "${CMAKE_BINARY_DIR}/bin/${test_name}.apk"
)
LIST(APPEND additional_clean_files "${CMAKE_BINARY_DIR}/bin/${test_target}-debug.apk" "${test_dir}/build.xml" "${test_dir}/local.properties" "${test_dir}/proguard.cfg")
LIST(APPEND additional_clean_files "${CMAKE_BINARY_DIR}/bin/${test_name}.apk" "${test_dir}/build.xml" "${test_dir}/local.properties" "${test_dir}/proguard.cfg")
endif()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${additional_clean_files}")

@ -29,7 +29,8 @@ if (BUILD_EXAMPLES)
macro(ADD_ANDROID_SAMPLE sample_name)
#message(STATUS "Build android sample: '${sample_name}'")
SET(sample_dir "${CMAKE_CURRENT_SOURCE_DIR}/${sample}")
#SET(sample_dir "${CMAKE_CURRENT_SOURCE_DIR}/${sample}")
SET(sample_dir "${CMAKE_CURRENT_BINARY_DIR}/${sample}")
add_custom_target(${sample} ALL)
add_dependencies(${sample} opencv_java opencv_java_api)
@ -52,10 +53,10 @@ if (BUILD_EXAMPLES)
COMMAND ${CMAKE_COMMAND} -E touch "${sample_dir}/default.properties"
COMMAND ${ANDROID_EXECUTABLE} update project --name "${sample}" --target android-8 ${opencv_reference} --path .
COMMAND ${ANT_EXECUTABLE} debug
COMMAND ${CMAKE_COMMAND} -E copy "${sample_dir}/bin/${sample}-debug.apk" "${CMAKE_BINARY_DIR}/bin/${sample}-debug.apk"
COMMAND ${CMAKE_COMMAND} -E copy "${sample_dir}/bin/${sample}-debug.apk" "${CMAKE_BINARY_DIR}/bin/${sample}.apk"
)
LIST(APPEND additional_clean_files "${CMAKE_BINARY_DIR}/bin/${sample}-debug.apk" "${sample_dir}/build.xml" "${sample_dir}/local.properties" "${sample_dir}/proguard.cfg")
LIST(APPEND additional_clean_files "${CMAKE_BINARY_DIR}/bin/${sample}.apk" "${sample_dir}/build.xml" "${sample_dir}/local.properties" "${sample_dir}/proguard.cfg")
if(IS_DIRECTORY "${sample_dir}/jni")
INCLUDE_DIRECTORIES("${sample_dir}/jni")
@ -87,6 +88,8 @@ if (BUILD_EXAMPLES)
file(GLOB android_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
list(REMOVE_ITEM android_samples hello-android)
list(SORT android_samples)
file(COPY ${android_samples} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" PATTERN ".svn" EXCLUDE)
foreach(sample ${android_samples})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${sample}/AndroidManifest.xml)

Loading…
Cancel
Save