CMakeLists.txt 2.4 KB

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