cmake: allow BUILD_FAT_JAVA_LIB for non-Android targets too

This commit is contained in:
Alexander Alekhin 2018-01-07 18:16:38 +00:00
parent ee35263e48
commit f3dde79ed6
4 changed files with 14 additions and 5 deletions

View File

@ -279,7 +279,7 @@ OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests"
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked OpenCV" ON IF MSVC )
OCV_OPTION(BUILD_WITH_DYNAMIC_IPP "Enables dynamic linking of IPP (only for standalone IPP)" OFF )
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create Java wrapper exporting all functions of OpenCV library (requires static build of OpenCV modules)" ANDROID IF NOT BUILD_SHARED_LIBS)
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID )
OCV_OPTION(BUILD_CUDA_STUBS "Build CUDA modules stubs when no CUDA SDK" OFF IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(BUILD_JAVA "Enable Java support" (ANDROID OR NOT CMAKE_CROSSCOMPILING) IF (ANDROID OR (NOT APPLE_FRAMEWORK AND NOT WINRT)) )
@ -1401,7 +1401,7 @@ endif()
# ========================== java ==========================
if(BUILD_JAVA OR BUILD_opencv_java)
status("")
status(" Java:")
status(" Java:" BUILD_FAT_JAVA_LIB THEN "export all functions" ELSE "")
status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
if(NOT ANDROID)
status(" JNI:" JNI_INCLUDE_DIRS THEN "${JNI_INCLUDE_DIRS}" ELSE NO)

View File

@ -886,7 +886,10 @@ macro(_ocv_create_module)
DEFINE_SYMBOL CVAPI_EXPORTS
)
if(ANDROID AND BUILD_FAT_JAVA_LIB)
if(BUILD_FAT_JAVA_LIB) # force exports from static modules too
if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "Assertion failed: BUILD_SHARED_LIBS=OFF must be off if BUILD_FAT_JAVA_LIB=ON")
endif()
target_compile_definitions(${the_module} PRIVATE CVAPI_EXPORTS)
endif()

View File

@ -452,6 +452,9 @@ macro(OCV_OPTION variable description value)
option(${variable} "${description}" ${__value})
endif()
else()
if(DEFINED ${variable})
# TODO: message(WARNING "Option will be ignored: ${variable} (=${${variable}})")
endif()
unset(${variable} CACHE)
endif()
unset(__condition)

View File

@ -442,8 +442,10 @@ if(BUILD_FAT_JAVA_LIB)
foreach(_dep ${__deps})
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-force_load "${_dep}")
endforeach()
else()
elseif(((CMAKE_COMPILER_IS_GNUCXX OR UNIX) OR (OPENCV_FORCE_FAT_JAVA_LIB_LD_RULES)) AND (NOT OPENCV_SKIP_FAT_JAVA_LIB_LD_RULES))
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
else()
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__deps})
endif()
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__extradeps} ${OPENCV_LINKER_LIBS})
else()
@ -480,8 +482,9 @@ if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_module} PROPERTIES FOLDER "bindings")
endif()
if(ANDROID)
if(BUILD_FAT_JAVA_LIB)
ocv_install_target(${the_module} OPTIONAL EXPORT OpenCVModules
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT java
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT java
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT java)
else()