Updated build scripts for better Java module support

This commit is contained in:
Andrey Kamaev 2011-06-24 07:48:04 +00:00
parent 2ee4f0de31
commit 69b79f89c1
12 changed files with 41 additions and 13 deletions

View File

@ -652,6 +652,13 @@ if(SPHINX_PROCESS EQUAL 0)
endif()
endif()
# Java support
# ===================================================
if (PYTHON_EXECUTABLE AND ANDROID)
SET(BUILD_JAVA_SUPPORT ON CACHE BOOL "Build with Java support")
else()
SET(BUILD_JAVA_SUPPORT OFF CACHE BOOL "Build with Java support" FORCE)
endif()
#YV
############################### QT ################################
@ -1566,6 +1573,7 @@ message(STATUS " Python numpy: YES")
else()
message(STATUS " Python numpy: NO (Python interface will not cover OpenCV 2.x API)")
endif()
message(STATUS " Java: ${BUILD_JAVA_SUPPORT}")
if(WITH_IPP AND IPP_FOUND)
message(STATUS " Use IPP: ${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")

View File

@ -5,7 +5,6 @@ if(ANDROID)
endif()
add_subdirectory(androidcamera)
add_subdirectory(java)
endif()
add_subdirectory(calib3d)
@ -31,6 +30,10 @@ if(PYTHONLIBS_FOUND AND BUILD_NEW_PYTHON_SUPPORT)
add_subdirectory(python)
endif()
if(BUILD_JAVA_SUPPORT)
add_subdirectory(java)
endif()
add_subdirectory(video)
add_subdirectory(traincascade)
add_subdirectory(haartraining)

View File

@ -24,12 +24,12 @@ foreach(module ${OPENCV_JAVA_MODULES})
list(SORT module_cppheaders)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}.java
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp
COMMAND ${PYTHON_EXECUTABLE} -B "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders}
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module}.java"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp"
COMMAND "${PYTHON_EXECUTABLE}" -B "${GEN_JAVA}" "${HDR_PARSER}" ${module} ${module_cheaders} ${module_cppheaders}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${GEN_JAVA}
DEPENDS ${HDR_PARSER}
DEPENDS "${GEN_JAVA}"
DEPENDS "${HDR_PARSER}"
DEPENDS ${module_headers}
)
endforeach()
@ -37,7 +37,7 @@ endforeach()
set(target "opencv_java")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
FILE(GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/srccpp/*.cpp")
FILE(GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp")
SET (generated_cpp_sources "")
SET (generated_java_sources "")
@ -75,25 +75,42 @@ set_target_properties(${target} PROPERTIES
INSTALL_NAME_DIR lib
)
add_custom_target(opecv_java_api ALL DEPENDS ${target})
set(api_target opencv_java_api)
add_custom_target(${api_target} ALL DEPENDS ${target})
IF(ANDROID)
# create Android library project in build folder
add_custom_command(TARGET opecv_java_api COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/res")
add_custom_command(
TARGET ${api_target}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/res"
COMMENT "Creating res directory"
)
FILE(GLOB android_lib_project_files "${CMAKE_CURRENT_SOURCE_DIR}/android/*")
foreach(lib_file ${android_lib_project_files})
if(NOT IS_DIRECTORY ${lib_file})
add_custom_command(TARGET opecv_java_api COMMAND ${CMAKE_COMMAND} -E copy "${lib_file}" "${CMAKE_BINARY_DIR}" DEPENDS "${lib_file}")
get_filename_component(lib_file_name "${lib_file}" NAME)
add_custom_command(
TARGET ${api_target}
COMMAND ${CMAKE_COMMAND} -E copy "${lib_file}" "${CMAKE_BINARY_DIR}"
DEPENDS "${lib_file}"
COMMENT "Generating ${lib_file_name}"
)
endif()
endforeach()
ENDIF()
FILE(GLOB java_project_files "${CMAKE_CURRENT_SOURCE_DIR}/srcjava/*.java")
FILE(GLOB java_project_files "${CMAKE_CURRENT_SOURCE_DIR}/src/java/*.java")
SET(JAVA_OUTPUT_DIR "${CMAKE_BINARY_DIR}/src/org/opencv")
add_custom_command(TARGET opecv_java_api COMMAND ${CMAKE_COMMAND} -E make_directory "${JAVA_OUTPUT_DIR}")
foreach(java_file ${java_project_files} ${generated_java_sources})
add_custom_command(TARGET opecv_java_api COMMAND ${CMAKE_COMMAND} -E copy "${java_file}" "${JAVA_OUTPUT_DIR}" DEPENDS "${java_file}" DEPENDS "${JAVA_OUTPUT_DIR}")
get_filename_component(java_file_name "${java_file}" NAME)
add_custom_command(
TARGET ${api_target}
COMMAND ${CMAKE_COMMAND} -E copy "${java_file}" "${JAVA_OUTPUT_DIR}/${java_file_name}"
DEPENDS "${java_file}"
DEPENDS "${JAVA_OUTPUT_DIR}"
COMMENT "Generating src/org/opencv/${java_file_name}"
)
endforeach()