OpenCVGenAndroidMK.cmake 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. if(ANDROID)
  2. # --------------------------------------------------------------------------------------------
  3. # Installation for Android ndk-build makefile: OpenCV.mk
  4. # Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
  5. # Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
  6. # -------------------------------------------------------------------------------------------
  7. # build type
  8. if(BUILD_SHARED_LIBS)
  9. set(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
  10. else()
  11. set(OPENCV_LIBTYPE_CONFIGMAKE "STATIC")
  12. endif()
  13. if(BUILD_FAT_JAVA_LIB)
  14. set(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
  15. set(OPENCV_STATIC_LIBTYPE_CONFIGMAKE "STATIC")
  16. else()
  17. set(OPENCV_STATIC_LIBTYPE_CONFIGMAKE ${OPENCV_LIBTYPE_CONFIGMAKE})
  18. endif()
  19. # build the list of opencv libs and dependencies for all modules
  20. ocv_get_all_libs(OPENCV_MODULES OPENCV_EXTRA_COMPONENTS OPENCV_3RDPARTY_COMPONENTS)
  21. # list -> string
  22. foreach(_var OPENCV_MODULES OPENCV_EXTRA_COMPONENTS OPENCV_3RDPARTY_COMPONENTS)
  23. set(var "${_var}_CONFIGMAKE")
  24. set(${var} "")
  25. foreach(lib ${${_var}})
  26. set(lib_name "${lib}")
  27. if(TARGET ${lib})
  28. get_target_property(_output ${lib} IMPORTED_LOCATION)
  29. if(NOT _output)
  30. get_target_property(output_name ${lib} OUTPUT_NAME)
  31. if(output_name)
  32. set(lib_name "${output_name}")
  33. endif()
  34. else()
  35. ocv_get_libname(lib_name "${_output}")
  36. endif()
  37. endif()
  38. set(${var} "${${var}} ${lib_name}")
  39. endforeach()
  40. string(STRIP "${${var}}" ${var})
  41. endforeach()
  42. # replace 'opencv_<module>' -> '<module>''
  43. string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
  44. if(BUILD_FAT_JAVA_LIB)
  45. set(OPENCV_LIBS_CONFIGMAKE java4)
  46. else()
  47. set(OPENCV_LIBS_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
  48. endif()
  49. # -------------------------------------------------------------------------------------------
  50. # Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
  51. # -------------------------------------------------------------------------------------------
  52. set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
  53. set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${OpenCV_SOURCE_DIR}\"")
  54. set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(OPENCV_TARGET_ARCH_ABI)")
  55. set(OPENCV_LIBS_ARCHIVE_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(OPENCV_TARGET_ARCH_ABI)")
  56. set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(OPENCV_TARGET_ARCH_ABI)")
  57. configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" @ONLY)
  58. configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/OpenCV-${ANDROID_NDK_ABI_NAME}.mk" @ONLY)
  59. # -------------------------------------------------------------------------------------------
  60. # Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
  61. # -------------------------------------------------------------------------------------------
  62. set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include\"")
  63. set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "")
  64. set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../libs/\$(OPENCV_TARGET_ARCH_ABI)")
  65. set(OPENCV_LIBS_ARCHIVE_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../staticlibs/\$(OPENCV_TARGET_ARCH_ABI)")
  66. set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(OPENCV_TARGET_ARCH_ABI)")
  67. configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" @ONLY)
  68. configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV-abi.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV-${ANDROID_NDK_ABI_NAME}.mk" @ONLY)
  69. install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev)
  70. install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV-${ANDROID_NDK_ABI_NAME}.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev)
  71. endif(ANDROID)