Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/java/jni/CMakeLists.txt
16337 views
1
project(${the_module})
2
3
glob_more_specific_sources(H "${CMAKE_CURRENT_SOURCE_DIR}/../generator/src" handwritten_h_sources)
4
glob_more_specific_sources(CPP "${CMAKE_CURRENT_SOURCE_DIR}/../generator/src" handwritten_cpp_sources)
5
6
# grab C++ files from misc/java
7
foreach(m ${OPENCV_MODULES_BUILD})
8
if (";${OPENCV_MODULE_${m}_WRAPPERS};" MATCHES ";java;" AND HAVE_${m})
9
set(module_java_dir "${OPENCV_MODULE_${m}_LOCATION}/misc/java")
10
include_directories("${module_java_dir}/src/cpp")
11
file(GLOB _result "${module_java_dir}/src/cpp/*.h" "${module_java_dir}/src/cpp/*.hpp" "${module_java_dir}/src/cpp/*.cpp")
12
list(APPEND handwritten_cpp_sources ${_result})
13
endif()
14
endforeach()
15
16
set(__type MODULE)
17
if(BUILD_FAT_JAVA_LIB)
18
set(__type SHARED) # samples link to libopencv_java
19
elseif(APPLE)
20
set(CMAKE_SHARED_MODULE_SUFFIX ".dylib") # Java is not able to load .so files
21
endif()
22
ocv_add_library(${the_module} ${__type}
23
${handwritten_h_sources} ${handwritten_cpp_sources} ${generated_cpp_sources}
24
${copied_files}
25
)
26
add_dependencies(${the_module} gen_opencv_java_source)
27
28
ocv_target_include_directories(${the_module} "${CMAKE_CURRENT_SOURCE_DIR}/../generator/src/cpp")
29
ocv_target_include_directories(${the_module} "${OPENCV_JAVA_BINDINGS_DIR}/gen/cpp")
30
ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
31
if(NOT ANDROID)
32
ocv_target_include_directories(${the_module} SYSTEM ${JNI_INCLUDE_DIRS})
33
endif()
34
35
set(__deps ${OPENCV_MODULE_${the_module}_DEPS})
36
list(REMOVE_ITEM __deps opencv_java_bindings_generator) # don't add dummy module to target_link_libraries list
37
38
if(BUILD_FAT_JAVA_LIB)
39
ocv_list_unique(__deps)
40
set(__extradeps ${__deps})
41
ocv_list_filterout(__extradeps "^opencv_")
42
if(__extradeps)
43
list(REMOVE_ITEM __deps ${__extradeps})
44
endif()
45
if(APPLE)
46
foreach(_dep ${__deps})
47
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-force_load "${_dep}")
48
endforeach()
49
elseif(((CV_GCC OR CV_CLANG OR UNIX) OR (OPENCV_FORCE_FAT_JAVA_LIB_LD_RULES)) AND (NOT OPENCV_SKIP_FAT_JAVA_LIB_LD_RULES))
50
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
51
else()
52
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__deps})
53
endif()
54
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__extradeps} ${OPENCV_LINKER_LIBS})
55
else()
56
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__deps} ${OPENCV_LINKER_LIBS})
57
endif()
58
59
# Additional target properties
60
set_target_properties(${the_module} PROPERTIES
61
OUTPUT_NAME "${the_module}${OPENCV_JAVA_LIB_NAME_SUFFIX}"
62
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
63
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
64
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
65
DEFINE_SYMBOL CVAPI_EXPORTS
66
)
67
68
if(ANDROID)
69
ocv_target_link_libraries(${the_module} LINK_PUBLIC jnigraphics) # for Mat <=> Bitmap converters
70
ocv_target_link_libraries(${the_module} LINK_PUBLIC log dl z)
71
72
# force strip library after the build command
73
# because samples and tests will make a copy of the library before install
74
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
75
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${the_module}>")
76
endif()
77
endif()
78
79
if(ENABLE_SOLUTION_FOLDERS)
80
set_target_properties(${the_module} PROPERTIES FOLDER "bindings")
81
endif()
82
83
set(__install_export "")
84
if(BUILD_FAT_JAVA_LIB)
85
set(__install_export EXPORT OpenCVModules)
86
endif()
87
88
ocv_install_target(${the_module} OPTIONAL ${__install_export}
89
RUNTIME DESTINATION ${OPENCV_JNI_BIN_INSTALL_PATH} COMPONENT java
90
LIBRARY DESTINATION ${OPENCV_JNI_INSTALL_PATH} COMPONENT java
91
ARCHIVE DESTINATION ${OPENCV_JNI_INSTALL_PATH} COMPONENT java
92
)
93
94