Merge pull request #15024 from alalek:android_stl_cxx_shared

This commit is contained in:
Alexander Alekhin 2019-07-16 17:10:04 +00:00
commit 65d148d9a8
7 changed files with 46 additions and 5 deletions

View File

@ -123,6 +123,16 @@ foreach(file ${seed_project_files_rel})
endif()
endforeach()
# copy libcxx_helper
set(__base_dir "${CMAKE_CURRENT_SOURCE_DIR}/")
file(GLOB_RECURSE __files_rel RELATIVE "${__base_dir}/" "${__base_dir}/libcxx_helper/*")
foreach(file ${__files_rel})
configure_file("${__base_dir}/${file}" "${OPENCV_JAVA_DIR}/${file}" @ONLY)
list(APPEND depends "${__base_dir}/${file}")
get_filename_component(install_subdir "${file}" PATH)
install(FILES "${OPENCV_JAVA_DIR}/${file}" DESTINATION "${JAVA_INSTALL_ROOT}/../${install_subdir}" COMPONENT java)
endforeach()
list(APPEND depends gen_opencv_java_source "${OPENCV_DEPHELPER}/gen_opencv_java_source")
ocv_copyfiles_add_target(${the_module}_android_source_copy JAVA_SRC_COPY "Copy Java(Andoid SDK) source files" ${depends})
file(REMOVE "${OPENCV_DEPHELPER}/${the_module}_android_source_copy") # force rebuild after CMake run

View File

@ -7,6 +7,13 @@ android {
defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=@ANDROID_STL@"
targets "opencv_jni_shared"
}
}
}
buildTypes {
@ -37,6 +44,12 @@ android {
manifest.srcFile 'AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}
}
dependencies {

View File

@ -99,6 +99,13 @@ android {
defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=@ANDROID_STL@"
targets "opencv_jni_shared"
}
}
}
buildTypes {
@ -129,6 +136,12 @@ android {
manifest.srcFile 'java/AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}
}
dependencies {

View File

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.6)
# dummy target to bring libc++_shared.so into packages
add_library(opencv_jni_shared STATIC dummy.cpp)

View File

@ -0,0 +1 @@
// empty

View File

@ -112,10 +112,10 @@ class TestCmakeBuild(unittest.TestCase):
def suite(workdir, opencv_cmake_path):
abis = {
"armeabi-v7a": { "ANDROID_ABI": "armeabi-v7a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"arm64-v8a": { "ANDROID_ABI": "arm64-v8a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86": { "ANDROID_ABI": "x86", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86_64": { "ANDROID_ABI": "x86_64", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"armeabi-v7a": { "ANDROID_ABI": "armeabi-v7a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"arm64-v8a": { "ANDROID_ABI": "arm64-v8a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86": { "ANDROID_ABI": "x86", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86_64": { "ANDROID_ABI": "x86_64", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
}
suite = unittest.TestSuite()

View File

@ -125,7 +125,7 @@ class ABI:
self.cmake_vars['ANDROID_TOOLCHAIN_NAME'] = toolchain
else:
self.cmake_vars['ANDROID_TOOLCHAIN'] = 'clang'
self.cmake_vars['ANDROID_STL'] = 'c++_static'
self.cmake_vars['ANDROID_STL'] = 'c++_shared'
if ndk_api_level:
self.cmake_vars['ANDROID_NATIVE_API_LEVEL'] = ndk_api_level
self.cmake_vars.update(cmake_vars)