From 3804ca3e20597772f2703f71ea23d5d23e3546e8 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Wed, 27 Jun 2012 06:22:26 +0000 Subject: [PATCH] changing package layout after 'make install' for Android build --- 3rdparty/libjasper/CMakeLists.txt | 4 ++-- 3rdparty/libjpeg/CMakeLists.txt | 4 ++-- 3rdparty/libpng/CMakeLists.txt | 4 ++-- 3rdparty/libtiff/CMakeLists.txt | 4 ++-- 3rdparty/tbb/CMakeLists.txt | 4 ++-- 3rdparty/zlib/CMakeLists.txt | 4 ++-- CMakeLists.txt | 18 +++++++++++---- android/scripts/cmake_android.cmd | 2 +- android/scripts/cmake_android.sh | 2 +- cmake/OpenCVDetectAndroidSDK.cmake | 29 +++++++++++++++++++++--- cmake/OpenCVGenAndroidMK.cmake | 10 ++++---- cmake/OpenCVGenConfig.cmake | 19 +++++++--------- cmake/templates/OpenCV.mk.in | 15 ++++++------ cmake/templates/OpenCVConfig.cmake.in | 4 ++-- data/CMakeLists.txt | 7 ++++-- modules/java/CMakeLists.txt | 14 ++++++++---- samples/CMakeLists.txt | 8 ++++--- samples/android/face-detection/jni/Android.mk | 13 ++++------- samples/android/tutorial-3-native/jni/Android.mk | 11 +-------- samples/android/tutorial-4-mixed/jni/Android.mk | 12 +--------- 20 files changed, 104 insertions(+), 84 deletions(-) diff --git a/3rdparty/libjasper/CMakeLists.txt b/3rdparty/libjasper/CMakeLists.txt index ab505d5..5b850c9 100644 --- a/3rdparty/libjasper/CMakeLists.txt +++ b/3rdparty/libjasper/CMakeLists.txt @@ -36,7 +36,7 @@ set_target_properties(${JASPER_LIBRARY} PROPERTIES OUTPUT_NAME ${JASPER_LIBRARY} DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -44,6 +44,6 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${JASPER_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${JASPER_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/libjpeg/CMakeLists.txt b/3rdparty/libjpeg/CMakeLists.txt index 46eaab1..708e63e 100644 --- a/3rdparty/libjpeg/CMakeLists.txt +++ b/3rdparty/libjpeg/CMakeLists.txt @@ -30,7 +30,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align -Wshadow -Wunused) set_target_properties(${JPEG_LIBRARY} PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY} DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH} + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -38,5 +38,5 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${JPEG_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${JPEG_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt index bfbf501..41d57f3 100644 --- a/3rdparty/libpng/CMakeLists.txt +++ b/3rdparty/libpng/CMakeLists.txt @@ -26,7 +26,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align) set_target_properties(${PNG_LIBRARY} PROPERTIES OUTPUT_NAME ${PNG_LIBRARY} DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -34,5 +34,5 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${PNG_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${PNG_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/libtiff/CMakeLists.txt b/3rdparty/libtiff/CMakeLists.txt index 991df08..ed9d1c8 100644 --- a/3rdparty/libtiff/CMakeLists.txt +++ b/3rdparty/libtiff/CMakeLists.txt @@ -102,7 +102,7 @@ set_target_properties(${TIFF_LIBRARY} PROPERTIES OUTPUT_NAME "${TIFF_LIBRARY}" DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -110,5 +110,5 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${TIFF_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${TIFF_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() diff --git a/3rdparty/tbb/CMakeLists.txt b/3rdparty/tbb/CMakeLists.txt index 63d6455..cf26ff0 100644 --- a/3rdparty/tbb/CMakeLists.txt +++ b/3rdparty/tbb/CMakeLists.txt @@ -128,7 +128,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/a set_target_properties(tbb PROPERTIES OUTPUT_NAME tbb DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -136,7 +136,7 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS tbb ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS tbb ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() # get TBB version diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index f4315e7..17bfab4 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -87,7 +87,7 @@ ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 -Wattributes -Wstrict-prototypes -Wmi set_target_properties(${ZLIB_LIBRARY} PROPERTIES OUTPUT_NAME ${ZLIB_LIBRARY} DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}" + ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ) if(ENABLE_SOLUTION_FOLDERS) @@ -95,7 +95,7 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(NOT BUILD_SHARED_LIBS) - install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH} COMPONENT main) + install(TARGETS ${ZLIB_LIBRARY} ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main) endif() ocv_parse_header2(ZLIB "${CMAKE_CURRENT_SOURCE_DIR}/zlib.h" ZLIB_VERSION PARENT_SCOPE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f4eebe..fc1c8a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ if(NOT CMAKE_TOOLCHAIN_FILE) else(NOT CMAKE_TOOLCHAIN_FILE) #Android: set output folder to ${CMAKE_BINARY_DIR} set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" ) + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory") endif(NOT CMAKE_TOOLCHAIN_FILE) # -------------------------------------------------------------- @@ -217,7 +218,6 @@ include(cmake/OpenCVVersion.cmake REQUIRED) # ---------------------------------------------------------------------------- # Save libs and executables in the same place -set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Output directory for libraries" ) set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" ) if(ANDROID OR WIN32) @@ -229,15 +229,25 @@ else() endif() if(ANDROID) - set(OPENCV_LIB_INSTALL_PATH libs/${ANDROID_NDK_ABI_NAME}) + set( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}") + set(3P_LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}") + set( OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME}) + set(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME}) else() - set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX}) + set( LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") + set(3P_LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}") + set( OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX}) + set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}) endif() set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -set(OPENCV_INCLUDE_PREFIX include) +if(ANDROID) + set(OPENCV_INCLUDE_PREFIX sdk/native/jni/include) +else() + set(OPENCV_INCLUDE_PREFIX include) +endif() if(INSTALL_TO_MANGLED_PATHS) set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION}) endif() diff --git a/android/scripts/cmake_android.cmd b/android/scripts/cmake_android.cmd index dc9e260..3e6d923 100644 --- a/android/scripts/cmake_android.cmd +++ b/android/scripts/cmake_android.cmd @@ -1,5 +1,5 @@ @ECHO OFF PUSHD %~dp0.. -CALL .\scripts\build.cmd %* +CALL .\scripts\build.cmd %* -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON POPD \ No newline at end of file diff --git a/android/scripts/cmake_android.sh b/android/scripts/cmake_android.sh index f2cbe48..101ba3c 100644 --- a/android/scripts/cmake_android.sh +++ b/android/scripts/cmake_android.sh @@ -4,5 +4,5 @@ cd `dirname $0`/.. mkdir -p build cd build -cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. +cmake -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index b1b7c76..95b5d69 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -218,7 +218,7 @@ macro(add_android_project target path) # get project sources file(GLOB_RECURSE android_proj_files RELATIVE "${path}" "${path}/res/*" "${path}/src/*") - ocv_list_filterout(android_proj_files ".svn") + ocv_list_filterout(android_proj_files "\\\\.svn") # copy sources out from the build tree set(android_proj_file_deps "") @@ -257,7 +257,7 @@ macro(add_android_project target path) # build native part file(GLOB_RECURSE android_proj_jni_files "${path}/jni/*.c" "${path}/jni/*.h" "${path}/jni/*.cpp" "${path}/jni/*.hpp") - ocv_list_filterout(android_proj_jni_files ".svn") + ocv_list_filterout(android_proj_jni_files "\\\\.svn") if(android_proj_jni_files AND EXISTS ${path}/jni/Android.mk AND NOT DEFINED JNI_LIB_NAME) file(STRINGS "${path}/jni/Android.mk" JNI_LIB_NAME REGEX "LOCAL_MODULE[ ]*:=[ ]*.*" ) @@ -313,7 +313,30 @@ macro(add_android_project target path) # put the final .apk to the OpenCV's bin folder add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${android_proj_bin_dir}/bin/${target}-debug.apk" "${OpenCV_BINARY_DIR}/bin/${target}.apk") if(INSTALL_ANDROID_EXAMPLES AND "${target}" MATCHES "^example-") - install(FILES "${OpenCV_BINARY_DIR}/bin/${target}.apk" DESTINATION "bin" COMPONENT main) + #apk + install(FILES "${OpenCV_BINARY_DIR}/bin/${target}.apk" DESTINATION "samples" COMPONENT main) + get_filename_component(sample_dir "${path}" NAME) + #java part + foreach(f ${android_proj_files} ${ANDROID_MANIFEST_FILE}) + get_filename_component(install_subdir "${f}" PATH) + install(FILES "${android_proj_bin_dir}/${f}" DESTINATION "samples/${sample_dir}/${install_subdir}" COMPONENT main) + endforeach() + #jni part + eclipse files + file(GLOB_RECURSE jni_files RELATIVE "${path}" "${path}/jni/*") + ocv_list_filterout(jni_files "\\\\.svn") + foreach(f ${jni_files} ".classpath" ".project" ".settings/org.eclipse.jdt.core.prefs") + get_filename_component(install_subdir "${f}" PATH) + install(FILES "${path}/${f}" DESTINATION "samples/${sample_dir}/${install_subdir}" COMPONENT main) + endforeach() + #update proj + if(android_proj_lib_deps_commands) + set(inst_lib_opt " --library ../../sdk/java") + endif() + install(CODE "EXECUTE_PROCESS(COMMAND ${ANDROID_EXECUTABLE} --silent update project --path . --target \"${android_proj_sdk_target}\" --name \"${target}\" ${inst_lib_opt} + WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}\" + )" COMPONENT main) + #empty 'gen' + install(CODE "MAKE_DIRECTORY(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}/gen\")" COMPONENT main) endif() endif() endmacro() diff --git a/cmake/OpenCVGenAndroidMK.cmake b/cmake/OpenCVGenAndroidMK.cmake index 0056d86..0812e62 100644 --- a/cmake/OpenCVGenAndroidMK.cmake +++ b/cmake/OpenCVGenAndroidMK.cmake @@ -82,17 +82,19 @@ if(ANDROID) # ------------------------------------------------------------------------------------------- set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"") set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${OpenCV_SOURCE_DIR}\"") - set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)") + set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(TARGET_ARCH_ABI)") + set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(TARGET_ARCH_ABI)") configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY) # ------------------------------------------------------------------------------------------- # Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install" # ------------------------------------------------------------------------------------------- - set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/../../include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/../../include\"") + set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include\"") set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "") - set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../..") + set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../libs/\$(TARGET_ARCH_ABI)") + set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(TARGET_ARCH_ABI)") configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY) - install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION share/OpenCV/) + install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION sdk/native/jni) endif(ANDROID) diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake index 0db9cdf..5cc3595 100644 --- a/cmake/OpenCVGenConfig.cmake +++ b/cmake/OpenCVGenConfig.cmake @@ -85,7 +85,7 @@ ocv_generate_dependencies_map_configcmake(DBG Debug) # ------------------------------------------------------------------------------------------- set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"") set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"${LIBRARY_OUTPUT_PATH}\"") -set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"") +set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${3P_LIBRARY_OUTPUT_PATH}\"") set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "") foreach(m ${OPENCV_MODULES_BUILD}) @@ -110,15 +110,10 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake. set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}\"") set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"") -if(ANDROID) - set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/libs/\${ANDROID_NDK_ABI_NAME}\"") - set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV/3rdparty/libs/\${ANDROID_NDK_ABI_NAME}\"") -else() - set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"") - set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"") - if(INSTALL_TO_MANGLED_PATHS) - set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV-${OPENCV_VERSION}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"") - endif() +set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"") +set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"") +if(INSTALL_TO_MANGLED_PATHS) + set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV-${OPENCV_VERSION}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"") endif() configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY) @@ -134,6 +129,8 @@ if(UNIX) math(EXPR SIZEOF_VOID_P_BITS "8 * ${CMAKE_SIZEOF_VOID_P}") if(LIB_SUFFIX AND NOT SIZEOF_VOID_P_BITS EQUAL LIB_SUFFIX) set(OPENCV_CONFIG_INSTALL_PREFIX lib${LIB_SUFFIX}/cmake/opencv) + elseif(ANDROID) + set(OPENCV_CONFIG_INSTALL_PREFIX sdk/native/jni) else() set(OPENCV_CONFIG_INSTALL_PREFIX share/OpenCV) endif() @@ -158,7 +155,7 @@ if(WIN32) set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/include\" \"\${OpenCV_CONFIG_PATH}/include/opencv\"") set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"") set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_LIB_INSTALL_PATH}\"") - set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"") + set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"") exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL) configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY) diff --git a/cmake/templates/OpenCV.mk.in b/cmake/templates/OpenCV.mk.in index 1120f20..e99b20e 100644 --- a/cmake/templates/OpenCV.mk.in +++ b/cmake/templates/OpenCV.mk.in @@ -7,6 +7,7 @@ LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir))))) OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir))) OPENCV_MK_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@ +OPENCV_3RDPARTY_LIBS_DIR:=@OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE@ OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@ OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@ OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@ @@ -31,9 +32,7 @@ else OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@ endif -ifeq (${OPENCV_CAMERA_MODULES},off) - OPENCV_CAMERA_MODULES:= -else +ifeq (${OPENCV_CAMERA_MODULES},on) ifeq ($(TARGET_ARCH_ABI),armeabi) OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_CONFIGCMAKE@ endif @@ -43,6 +42,8 @@ else ifeq ($(TARGET_ARCH_ABI),x86) OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_X86_CONFIGCMAKE@ endif +else + OPENCV_CAMERA_MODULES:= endif ifeq ($(OPENCV_LIB_TYPE),SHARED) @@ -55,21 +56,21 @@ endif define add_opencv_module include $(CLEAR_VARS) LOCAL_MODULE:=opencv_$1 - LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libs/$(TARGET_ARCH_ABI)/libopencv_$1.$(OPENCV_LIB_SUFFIX) + LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libopencv_$1.$(OPENCV_LIB_SUFFIX) include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY) endef define add_opencv_3rdparty_component include $(CLEAR_VARS) LOCAL_MODULE:=$1 - LOCAL_SRC_FILES:=$(OPENCV_THIS_DIR)/3rdparty/libs/$(TARGET_ARCH_ABI)/lib$1.a + LOCAL_SRC_FILES:=$(OPENCV_3RDPARTY_LIBS_DIR)/lib$1.a include $(PREBUILT_STATIC_LIBRARY) endef define add_opencv_camera_module include $(CLEAR_VARS) LOCAL_MODULE:=$1 - LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libs/$(TARGET_ARCH_ABI)/lib$1.so + LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/lib$1.so include $(PREBUILT_SHARED_LIBRARY) endef @@ -94,7 +95,7 @@ LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS) ifeq ($(OPENCV_INSTALL_MODULES),on) LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod)) else - LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)/libs/$(TARGET_ARCH_ABI)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib)) + LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib)) endif ifeq ($(OPENCV_LIB_TYPE),STATIC) diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index 95e3ba2..5b4f096 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -55,9 +55,9 @@ get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACH if(NOT WIN32) # Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8) - get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../.." ABSOLUTE) + get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../.." ABSOLUTE) else() - get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../.." REALPATH) + get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../.." REALPATH) endif() endif() diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 4a7f008..70efd6f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,7 +1,10 @@ file(GLOB HAAR_CASCADES haarcascades/*.xml) file(GLOB LBP_CASCADES lbpcascades/*.xml) -if(NOT WIN32) +if(ANDROID) + install(FILES ${HAAR_CASCADES} DESTINATION sdk/etc/haarcascades COMPONENT main) + install(FILES ${LBP_CASCADES} DESTINATION sdk/etc/lbpcascades COMPONENT main) +elseif(NOT WIN32) install(FILES ${HAAR_CASCADES} DESTINATION share/OpenCV/haarcascades COMPONENT main) - install(FILES ${LBP_CASCADES} DESTINATION share/OpenCV/lbpcascades COMPONENT main) + install(FILES ${LBP_CASCADES} DESTINATION share/OpenCV/lbpcascades COMPONENT main) endif() diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index af2b97a..020abb2 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -118,6 +118,8 @@ add_custom_command( # copy generated java files to the final location set(JAVA_OUTPUT_DIR "src/org/opencv") +set(JAVA_INSTALL_ROOT "sdk/java") +set(JNI_INSTALL_ROOT "sdk/native") # copy each documented header to the final destination set(java_files "") @@ -137,7 +139,7 @@ foreach(java_file ${documented_java_files} ${handwrittren_aidl_sources}) if(ANDROID) get_filename_component(install_subdir "${java_file_name}" PATH) - install(FILES "${OpenCV_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${JAVA_OUTPUT_DIR}/${install_subdir} COMPONENT main) + install(FILES "${OpenCV_BINARY_DIR}/${JAVA_OUTPUT_DIR}/${java_file_name}" DESTINATION ${JAVA_INSTALL_ROOT}/${JAVA_OUTPUT_DIR}/${install_subdir} COMPONENT main) endif() endforeach() @@ -199,7 +201,8 @@ if(ANDROID) list(APPEND lib_proj_files "${OpenCV_BINARY_DIR}/${f}") if(NOT f MATCHES "jni/.+") - install(FILES "${OpenCV_BINARY_DIR}/${f}" DESTINATION . COMPONENT main) + get_filename_component(install_subdir "${f}" PATH) + install(FILES "${OpenCV_BINARY_DIR}/${f}" DESTINATION "${JAVA_INSTALL_ROOT}/${install_subdir}" COMPONENT main) endif() endif() endforeach() @@ -235,8 +238,11 @@ if(ANDROID) DEPENDS ${lib_proj_files} COMMENT "Generating OpenCV Android library project. SDK target: ${lib_target_sdk_target}" ) - install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_PROJECT_PROPERTIES_FILE}" DESTINATION . COMPONENT main) - install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" DESTINATION . COMPONENT main) + install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_PROJECT_PROPERTIES_FILE}" DESTINATION ${JAVA_INSTALL_ROOT} COMPONENT main) + install(FILES "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}" DESTINATION ${JAVA_INSTALL_ROOT} COMPONENT main) + # creating empty 'gen' and 'res' folders + install(CODE "MAKE_DIRECTORY(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sdk/java/gen\")" COMPONENT main) + install(CODE "MAKE_DIRECTORY(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sdk/java/res\")" COMPONENT main) if(ANT_EXECUTABLE AND ANDROID_TOOLS_Pkg_Revision GREATER 13) # build the library project diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index b7ec3a3..cf4d20d 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -3,9 +3,11 @@ # # ---------------------------------------------------------------------------- -add_subdirectory(c) -add_subdirectory(cpp) -add_subdirectory(gpu) +if(NOT ANDROID) + add_subdirectory(c) + add_subdirectory(cpp) + add_subdirectory(gpu) +endif() if(ANDROID AND BUILD_ANDROID_EXAMPLES) add_subdirectory(android) diff --git a/samples/android/face-detection/jni/Android.mk b/samples/android/face-detection/jni/Android.mk index 190baf3..93f5ca4 100644 --- a/samples/android/face-detection/jni/Android.mk +++ b/samples/android/face-detection/jni/Android.mk @@ -2,15 +2,10 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -OPENCV_CAMERA_MODULES:=off - -include ../includeOpenCV.mk -ifeq ("$(wildcard $(OPENCV_MK_PATH))","") - #try to load OpenCV.mk from default install location - include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk -else - include $(OPENCV_MK_PATH) -endif +#OPENCV_CAMERA_MODULES:=off +#OPENCV_INSTALL_MODULES:=off +#OPENCV_LIB_TYPE:=SHARED +include ../../sdk/native/jni/OpenCV.mk LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp LOCAL_C_INCLUDES += $(LOCAL_PATH) diff --git a/samples/android/tutorial-3-native/jni/Android.mk b/samples/android/tutorial-3-native/jni/Android.mk index 7429d65..372d65a 100644 --- a/samples/android/tutorial-3-native/jni/Android.mk +++ b/samples/android/tutorial-3-native/jni/Android.mk @@ -2,16 +2,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -OPENCV_LIB_TYPE:=STATIC -OPENCV_INSTALL_MODULES:=on - -include ../includeOpenCV.mk -ifeq ("$(wildcard $(OPENCV_MK_PATH))","") - #try to load OpenCV.mk from default install location - include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk -else - include $(OPENCV_MK_PATH) -endif +include ../../sdk/native/jni/OpenCV.mk LOCAL_MODULE := native_sample LOCAL_SRC_FILES := jni_part.cpp diff --git a/samples/android/tutorial-4-mixed/jni/Android.mk b/samples/android/tutorial-4-mixed/jni/Android.mk index bd06352..18dac1f 100644 --- a/samples/android/tutorial-4-mixed/jni/Android.mk +++ b/samples/android/tutorial-4-mixed/jni/Android.mk @@ -2,17 +2,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -OPENCV_CAMERA_MODULES:=off -OPENCV_INSTALL_MODULES:=on -#OPENCV_LIB_TYPE:=SHARED <- this is default - -include ../includeOpenCV.mk -ifeq ("$(wildcard $(OPENCV_MK_PATH))","") - #try to load OpenCV.mk from default install location - include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk -else - include $(OPENCV_MK_PATH) -endif +include ../../sdk/native/jni/OpenCV.mk LOCAL_MODULE := mixed_sample LOCAL_SRC_FILES := jni_part.cpp -- 2.7.4