CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # ----------------------------------------------------------------------------
  2. # CMake file for Java tutorials compilation.
  3. #
  4. # ----------------------------------------------------------------------------
  5. if(NOT ANT_EXECUTABLE OR NOT TARGET opencv_java)
  6. return()
  7. endif()
  8. project(compile_java_tutorials)
  9. set(curdir "${CMAKE_CURRENT_SOURCE_DIR}")
  10. set(opencv_tutorial_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.compiled")
  11. set(TUTORIALS_DIRS "")
  12. file(GLOB children RELATIVE ${curdir} ${curdir}/*/*)
  13. foreach(child ${children})
  14. if(IS_DIRECTORY ${curdir}/${child})
  15. file(GLOB contains_java_files "${child}/*.java")
  16. if(contains_java_files)
  17. list(APPEND TUTORIALS_DIRS ${child})
  18. endif()
  19. endif()
  20. endforeach()
  21. add_custom_target("${PROJECT_NAME}"
  22. DEPENDS opencv_java
  23. )
  24. foreach(TUTORIAL_DIR ${TUTORIALS_DIRS})
  25. get_filename_component(TUTORIAL_NAME ${TUTORIAL_DIR} NAME_WE)
  26. add_custom_command(TARGET "${PROJECT_NAME}"
  27. COMMAND ${ANT_EXECUTABLE} -q
  28. -DocvJarDir="${OpenCV_BINARY_DIR}/bin"
  29. -DsrcDir="${TUTORIAL_DIR}"
  30. -DdstDir="${opencv_tutorial_java_bin_dir}/${TUTORIAL_NAME}"
  31. WORKING_DIRECTORY "${curdir}"
  32. COMMENT "Compile the tutorial: ${TUTORIAL_NAME}"
  33. )
  34. endforeach()