Fixed Android build
This commit is contained in:
parent
03c7784186
commit
c7bdf83de5
@ -245,11 +245,6 @@ endif()
|
|||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(ENABLE_PROFILING OFF CACHE BOOL "Enable profiling in the GCC compiler (Add flags: -g -pg)")
|
set(ENABLE_PROFILING OFF CACHE BOOL "Enable profiling in the GCC compiler (Add flags: -g -pg)")
|
||||||
set(USE_OMIT_FRAME_POINTER ON CACHE BOOL "Enable -fomit-frame-pointer for GCC")
|
set(USE_OMIT_FRAME_POINTER ON CACHE BOOL "Enable -fomit-frame-pointer for GCC")
|
||||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm*)
|
|
||||||
# We can use only -O2 because the -O3 causes gcc crash
|
|
||||||
set(USE_O2 ON CACHE BOOL "Enable -O2 for GCC")
|
|
||||||
set(USE_FAST_MATH ON CACHE BOOL "Enable -ffast-math for GCC")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*|x86_64*)
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*|x86_64*)
|
||||||
set(X86_64 1)
|
set(X86_64 1)
|
||||||
@ -257,7 +252,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||||||
|
|
||||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686*|i386*|x86*)
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686*|i386*|x86*)
|
||||||
set(X86 1)
|
set(X86 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES powerpc*)
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES powerpc*)
|
||||||
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
|
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
|
||||||
@ -1148,14 +1143,8 @@ set(CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\"${CMAKE_CURRENT_SOURCE_DIR}\"")
|
|||||||
|
|
||||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}")
|
set(CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}")
|
||||||
|
|
||||||
if (ANDROID)
|
if( HAVE_ANDROID_NATIVE_CAMERA )
|
||||||
if (NOT BUILD_SHARED_LIBS)
|
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} ${NativeCamera_LIB_DIR})
|
||||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} "${CMAKE_BINARY_DIR}/lib")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( HAVE_ANDROID_NATIVE_CAMERA )
|
|
||||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE ${CMAKE_LIB_DIRS_CONFIGCMAKE} ${NativeCamera_LIB_DIR})
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
||||||
|
@ -32,21 +32,27 @@ macro(define_opencv_module name)
|
|||||||
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs})
|
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs})
|
||||||
|
|
||||||
# For dynamic link numbering convenions
|
# For dynamic link numbering convenions
|
||||||
set_target_properties(${the_target} PROPERTIES
|
if(NOT ANDROID)
|
||||||
VERSION ${OPENCV_VERSION}
|
# Android SDK build scripts can include only .so files into final .apk
|
||||||
SOVERSION ${OPENCV_SOVERSION}
|
# As result we should not set version properties for Android
|
||||||
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
|
set_target_properties(${the_target} PROPERTIES
|
||||||
)
|
VERSION ${OPENCV_VERSION}
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
SOVERSION ${OPENCV_SOVERSION}
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" )
|
||||||
|
|
||||||
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
|
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
|
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DCVAPI_EXPORTS)
|
add_definitions(-DCVAPI_EXPORTS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Additional target properties
|
# Additional target properties
|
||||||
|
@ -105,3 +105,6 @@ SET( ENABLE_SSE42 OFF CACHE INTERNAL "" FORCE )
|
|||||||
|
|
||||||
#Enable SSSE3 instructions
|
#Enable SSSE3 instructions
|
||||||
SET( ENABLE_SSSE3 OFF CACHE INTERNAL "" FORCE )
|
SET( ENABLE_SSSE3 OFF CACHE INTERNAL "" FORCE )
|
||||||
|
|
||||||
|
#Set output folder to "libs" instead of "lib" for better compatibility with java projects
|
||||||
|
SET( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/libs CACHE PATH "path for android libs" )
|
||||||
|
@ -227,6 +227,7 @@ if( ARM_TARGET STREQUAL "armeabi" )
|
|||||||
set( ARMEABI true )
|
set( ARMEABI true )
|
||||||
set( ARMEABI_NDK_NAME "armeabi" )
|
set( ARMEABI_NDK_NAME "armeabi" )
|
||||||
set( NEON false )
|
set( NEON false )
|
||||||
|
set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
|
||||||
else()
|
else()
|
||||||
if( ARM_TARGET STREQUAL "armeabi-v7a with NEON" )
|
if( ARM_TARGET STREQUAL "armeabi-v7a with NEON" )
|
||||||
set( NEON true )
|
set( NEON true )
|
||||||
@ -240,6 +241,7 @@ Supported values are: \"armeabi\", \"armeabi-v7a\", \"armeabi-v7a with NEON\", \
|
|||||||
endif()
|
endif()
|
||||||
set( ARMEABI_V7A true )
|
set( ARMEABI_V7A true )
|
||||||
set( ARMEABI_NDK_NAME "armeabi-v7a" )
|
set( ARMEABI_NDK_NAME "armeabi-v7a" )
|
||||||
|
set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#setup output directories
|
#setup output directories
|
||||||
@ -248,8 +250,12 @@ set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library o
|
|||||||
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS OFF CACHE BOOL "")
|
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS OFF CACHE BOOL "")
|
||||||
if( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS )
|
if( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS )
|
||||||
#some cmake standard modules work incorrectly if output paths are changed
|
#some cmake standard modules work incorrectly if output paths are changed
|
||||||
set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" FORCE )
|
if( EXISTS ${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt )
|
||||||
set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ARMEABI_NDK_NAME} CACHE PATH "Output directory for applications" FORCE)
|
# these paths are required for jni part of Android projects
|
||||||
|
# but they may conflict with traditional unix makefile's folder structure
|
||||||
|
set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" FORCE )
|
||||||
|
set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ARMEABI_NDK_NAME} CACHE PATH "Output directory for applications" FORCE)
|
||||||
|
endif()
|
||||||
set( CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user/${ARMEABI_NDK_NAME} CACHE STRING "path for installing" FORCE )
|
set( CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user/${ARMEABI_NDK_NAME} CACHE STRING "path for installing" FORCE )
|
||||||
endif()
|
endif()
|
||||||
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS ON CACHE INTERNAL "" FORCE)
|
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS ON CACHE INTERNAL "" FORCE)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
:: variables required for OpenCV build ::
|
:: variables required for OpenCV build ::
|
||||||
|
:: Note: all pathes should be specified without tailing slashes!
|
||||||
SET ANDROID_NDK=C:\full\path\to\your\copy\of\android\NDK\android-ndk-r5b
|
SET ANDROID_NDK=C:\full\path\to\your\copy\of\android\NDK\android-ndk-r5b
|
||||||
SET CMAKE_EXE=C:\full\path\to\cmake\utility\cmake.exe
|
SET CMAKE_EXE=C:\full\path\to\cmake\utility\cmake.exe
|
||||||
SET MAKE_EXE=C:\full\path\to\native\port\of\make\utility\make.exe
|
SET MAKE_EXE=C:\full\path\to\native\port\of\make\utility\make.exe
|
||||||
@ -23,4 +24,4 @@ SET BUILD_DIR=build
|
|||||||
::SET BUILD_DIR=build_neon
|
::SET BUILD_DIR=build_neon
|
||||||
|
|
||||||
:::: other options
|
:::: other options
|
||||||
::SET ANDROID_API_LEVEL=8 &:: android-3 is enough for OpenCV but android-8 is recommended
|
::SET ANDROID_API_LEVEL=8 &:: android-3 is enough for OpenCV but android-8 is recommended
|
||||||
|
@ -273,11 +273,15 @@ if(PCHSupport_FOUND AND USE_PRECOMPILED_HEADERS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# For dynamic link numbering convenions
|
# For dynamic link numbering convenions
|
||||||
set_target_properties(${the_target} PROPERTIES
|
if(NOT ANDROID)
|
||||||
VERSION ${OPENCV_VERSION}
|
# Android SDK build scripts can include only .so files into final .apk
|
||||||
SOVERSION ${OPENCV_SOVERSION}
|
set_target_properties(${the_target} PROPERTIES
|
||||||
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
|
VERSION ${OPENCV_VERSION}
|
||||||
)
|
SOVERSION ${OPENCV_SOVERSION}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" )
|
||||||
|
|
||||||
# Additional target properties
|
# Additional target properties
|
||||||
set_target_properties(${the_target} PROPERTIES
|
set_target_properties(${the_target} PROPERTIES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user