CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. if(OPENCV_INITIAL_PASS)
  2. # generator for JNI/JAR source code and documentation signatures
  3. add_subdirectory(generator)
  4. endif()
  5. if(APPLE_FRAMEWORK OR WINRT
  6. OR NOT PYTHON_DEFAULT_AVAILABLE
  7. OR NOT (ANT_EXECUTABLE OR Java_FOUND OR ANDROID_PROJECTS_BUILD_TYPE STREQUAL "GRADLE")
  8. OR NOT (JNI_FOUND OR (ANDROID AND (NOT DEFINED ANDROID_NATIVE_API_LEVEL OR ANDROID_NATIVE_API_LEVEL GREATER 7)))
  9. OR BUILD_opencv_world
  10. )
  11. ocv_module_disable(java)
  12. endif()
  13. set(the_description "The java bindings")
  14. ocv_add_module(java BINDINGS opencv_core opencv_imgproc PRIVATE_REQUIRED opencv_java_bindings_generator)
  15. include(${CMAKE_CURRENT_SOURCE_DIR}/common.cmake)
  16. # UTILITY: glob specific sources and append them to list (type is in H, CPP, JAVA, AIDL)
  17. macro(glob_more_specific_sources _type _root _output)
  18. unset(_masks)
  19. if(${_type} STREQUAL "H")
  20. set(_masks "${_root}/cpp/*.h" "${_root}/cpp/*.hpp")
  21. elseif(${_type} STREQUAL "CPP")
  22. set(_masks "${_root}/cpp/*.cpp")
  23. elseif(${_type} STREQUAL "JAVA")
  24. set(_masks "${_root}/java/*.java" "${_root}/java/*.java.in")
  25. elseif(${_type} STREQUAL "AIDL")
  26. set(_masks "${_root}/java/*.aidl")
  27. endif()
  28. if (_masks)
  29. file(GLOB _result ${_masks})
  30. list(APPEND ${_output} ${_result})
  31. else()
  32. message(WARNING "Bad argument passed to macro: skipped")
  33. endif()
  34. endmacro()
  35. # UTILITY: copy common java test files and add them to _deps
  36. # copy_common_tests(<source-folder> <destination-folder> <variable-to-store-deps>)
  37. macro(copy_common_tests _src_location _dst_location _deps)
  38. set(_src ${_src_location})
  39. set(_dst ${_dst_location})
  40. file(GLOB_RECURSE _files RELATIVE "${_src}" "${_src}/res/*" "${_src}/src/*")
  41. foreach(f ${_files})
  42. add_custom_command(
  43. OUTPUT "${_dst}/${f}"
  44. COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_src}/${f}" "${_dst}/${f}"
  45. MAIN_DEPENDENCY "${_src}/${f}"
  46. COMMENT "Copying ${f}")
  47. list(APPEND ${_deps} "${_src}/${f}" "${_dst}/${f}")
  48. endforeach()
  49. unset(_files)
  50. unset(_src)
  51. unset(_dst)
  52. endmacro()
  53. add_subdirectory(jni) # generates ${the_module} target (${the_module}_jni doesn't work properly with Android non-gradle samples)
  54. if(ANDROID)
  55. add_subdirectory(android_sdk) # generates ${the_module}_android target
  56. else()
  57. add_subdirectory(jar) # generates ${the_module}_jar target
  58. endif()
  59. if(BUILD_TESTS)
  60. if(ANDROID)
  61. add_subdirectory(test/android_test)
  62. else()
  63. add_subdirectory(test/pure_test)
  64. endif()
  65. endif()