Merge pull request #8993 from Cartucho:compiling_java_code

This commit is contained in:
Alexander Alekhin 2017-06-28 12:26:29 +00:00
commit 20f603a217
3 changed files with 53 additions and 0 deletions

View File

@ -11,6 +11,7 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
# ----------------------------------------------------------------------------
add_subdirectory(cpp)
add_subdirectory(java/tutorial_code)
add_subdirectory(dnn)
add_subdirectory(gpu)
add_subdirectory(tapi)

View File

@ -0,0 +1,39 @@
# ----------------------------------------------------------------------------
# CMake file for Java tutorials compilation.
#
# ----------------------------------------------------------------------------
if(NOT ANT_EXECUTABLE OR NOT TARGET opencv_java)
return()
endif()
project(compile_java_tutorials)
set(curdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(opencv_tutorial_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.compiled")
set(TUTORIALS_DIRS "")
file(GLOB children RELATIVE ${curdir} ${curdir}/*/*)
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
file(GLOB contains_java_files "${child}/*.java")
if(contains_java_files)
list(APPEND TUTORIALS_DIRS ${child})
endif()
endif()
endforeach()
add_custom_target("${PROJECT_NAME}"
DEPENDS opencv_java
)
foreach(TUTORIAL_DIR ${TUTORIALS_DIRS})
get_filename_component(TUTORIAL_NAME ${TUTORIAL_DIR} NAME_WE)
add_custom_command(TARGET "${PROJECT_NAME}"
COMMAND ${ANT_EXECUTABLE} -q
-DocvJarDir="${OpenCV_BINARY_DIR}/bin"
-DsrcDir="${TUTORIAL_DIR}"
-DdstDir="${opencv_tutorial_java_bin_dir}/${TUTORIAL_NAME}"
WORKING_DIRECTORY "${curdir}"
COMMENT "Compile the tutorial: ${TUTORIAL_NAME}"
)
endforeach()

View File

@ -0,0 +1,13 @@
<project default="compile">
<property name="lib.dir" value="${ocvJarDir}"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="compile">
<mkdir dir="${dstDir}"/>
<javac includeantruntime="false" srcdir="${srcDir}" destdir="${dstDir}" classpathref="classpath"/>
</target>
</project>