mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Extracted install layout configuration to separate file
This commit is contained in:
parent
a7b954f655
commit
4e67eb6c42
134
CMakeLists.txt
134
CMakeLists.txt
@ -498,9 +498,21 @@ ocv_cmake_hook(POST_OPTIONS)
|
||||
# Build & install layouts
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(OPENCV_TEST_DATA_PATH)
|
||||
get_filename_component(OPENCV_TEST_DATA_PATH ${OPENCV_TEST_DATA_PATH} ABSOLUTE)
|
||||
endif()
|
||||
|
||||
# Save libs and executables in the same place
|
||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications")
|
||||
|
||||
if(ANDROID)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
|
||||
ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
if(ANDROID_ABI MATCHES "NEON")
|
||||
set(ENABLE_NEON ON)
|
||||
@ -510,126 +522,6 @@ if(ANDROID)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID OR WIN32)
|
||||
ocv_update(OPENCV_DOC_INSTALL_PATH doc)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||
if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH)
|
||||
ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "${OpenCV_ARCH}/${OpenCV_RUNTIME}/")
|
||||
else()
|
||||
message(STATUS "Can't detect runtime and/or arch")
|
||||
ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
elseif(ANDROID)
|
||||
ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "sdk/native/")
|
||||
else()
|
||||
ocv_update(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
ocv_update(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
ocv_update(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_TEST_INSTALL_PATH)
|
||||
ocv_update(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
endif()
|
||||
|
||||
if (OPENCV_TEST_DATA_PATH)
|
||||
get_filename_component(OPENCV_TEST_DATA_PATH ${OPENCV_TEST_DATA_PATH} ABSOLUTE)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "sdk/etc/testdata")
|
||||
elseif(WIN32)
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "testdata")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME})
|
||||
ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH sdk/native/staticlibs/${ANDROID_NDK_ABI_NAME})
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME})
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH sdk/native/jni)
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH sdk/native/jni/include)
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH sdk/etc)
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/licenses")
|
||||
else()
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
|
||||
ocv_update(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
|
||||
|
||||
if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||
if(OpenCV_STATIC)
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
||||
else()
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples)
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH java)
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH etc)
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH ".")
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH "include")
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/licenses")
|
||||
else()
|
||||
# Note: layout differs from OpenCV 3.4
|
||||
include(GNUInstallDirs)
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/opencv4")
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}")
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}/cmake/opencv4")
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}/opencv4/3rdparty")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/opencv4/samples")
|
||||
ocv_update(OPENCV_DOC_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/doc/opencv4")
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/java/opencv4")
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/opencv4/testdata")
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/opencv4")
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/licenses/opencv4")
|
||||
endif()
|
||||
#ocv_update(OPENCV_PYTHON_INSTALL_PATH "python") # no default value, see https://github.com/opencv/opencv/issues/13202
|
||||
endif()
|
||||
|
||||
ocv_update(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
if(INSTALL_TO_MANGLED_PATHS)
|
||||
foreach(v
|
||||
OPENCV_INCLUDE_INSTALL_PATH
|
||||
# file names include version (.so/.dll): OPENCV_LIB_INSTALL_PATH
|
||||
OPENCV_CONFIG_INSTALL_PATH
|
||||
OPENCV_3P_LIB_INSTALL_PATH
|
||||
OPENCV_SAMPLES_SRC_INSTALL_PATH
|
||||
OPENCV_DOC_INSTALL_PATH
|
||||
# JAR file name includes version: OPENCV_JAR_INSTALL_PATH
|
||||
OPENCV_TEST_DATA_INSTALL_PATH
|
||||
OPENCV_OTHER_INSTALL_PATH
|
||||
)
|
||||
string(REGEX REPLACE "opencv[0-9]*" "opencv-${OPENCV_VERSION}" ${v} "${${v}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}")
|
||||
elseif(INSTALL_CREATE_DISTRIB)
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "${OPENCV_JAR_INSTALL_PATH}/${OpenCV_ARCH}")
|
||||
else()
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "${OPENCV_JAR_INSTALL_PATH}")
|
||||
endif()
|
||||
ocv_update(OPENCV_JNI_BIN_INSTALL_PATH "${OPENCV_JNI_INSTALL_PATH}")
|
||||
|
||||
if(NOT OPENCV_LIB_ARCHIVE_INSTALL_PATH)
|
||||
set(OPENCV_LIB_ARCHIVE_INSTALL_PATH ${OPENCV_LIB_INSTALL_PATH})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# Postfix of DLLs:
|
||||
ocv_update(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
|
||||
@ -648,6 +540,8 @@ if((INSTALL_CREATE_DISTRIB AND BUILD_SHARED_LIBS AND NOT DEFINED BUILD_opencv_wo
|
||||
set(BUILD_opencv_world ON CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVInstallLayout.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Path for build/platform -specific headers
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@ -186,11 +186,7 @@ if(NOT ${found})
|
||||
else() #debian based assumed, install to the dist-packages.
|
||||
set(_packages_path "python${_version_major_minor}/dist-packages")
|
||||
endif()
|
||||
if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}")
|
||||
set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}")
|
||||
else()
|
||||
set(_packages_path "lib/${_packages_path}")
|
||||
endif()
|
||||
set(_packages_path "lib/${_packages_path}")
|
||||
elseif(CMAKE_HOST_WIN32)
|
||||
get_filename_component(_path "${_executable}" PATH)
|
||||
file(TO_CMAKE_PATH "${_path}" _path)
|
||||
|
@ -123,12 +123,7 @@ endif()
|
||||
# --------------------------------------------------------------------------------------------
|
||||
if(WIN32)
|
||||
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(_lib_suffix "lib")
|
||||
else()
|
||||
set(_lib_suffix "staticlib")
|
||||
endif()
|
||||
ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "${OpenCV_INSTALL_BINARIES_PREFIX}${_lib_suffix}" "OpenCVConfig.root-WIN32.cmake.in")
|
||||
ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "${OPENCV_LIB_INSTALL_PATH}" "OpenCVConfig.root-WIN32.cmake.in")
|
||||
else()
|
||||
ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "" "")
|
||||
endif()
|
||||
|
101
cmake/OpenCVInstallLayout.cmake
Normal file
101
cmake/OpenCVInstallLayout.cmake
Normal file
@ -0,0 +1,101 @@
|
||||
# message(STATUS "Initial install layout:")
|
||||
# ocv_cmake_dump_vars("OPENCV_.*_INSTALL_PATH")
|
||||
|
||||
if(ANDROID)
|
||||
|
||||
ocv_update(OPENCV_BIN_INSTALL_PATH "sdk/native/bin/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "sdk/native/samples/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "sdk/native/libs/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH "sdk/native/staticlibs/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME}")
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH "sdk/native/jni")
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH "sdk/native/jni/include")
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH "sdk/etc")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH "samples/native")
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/licenses")
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/testdata")
|
||||
ocv_update(OPENCV_DOC_INSTALL_PATH "doc")
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH ".")
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_JNI_BIN_INSTALL_PATH "${OPENCV_JNI_INSTALL_PATH}")
|
||||
|
||||
elseif(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||
|
||||
if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH)
|
||||
set(_prefix "${OpenCV_ARCH}/${OpenCV_RUNTIME}/")
|
||||
else()
|
||||
message(STATUS "Can't detect runtime and/or arch")
|
||||
set(_prefix "")
|
||||
endif()
|
||||
if(OpenCV_STATIC)
|
||||
set(_suffix "staticlib")
|
||||
else()
|
||||
set(_suffix "lib")
|
||||
endif()
|
||||
if(INSTALL_CREATE_DISTRIB)
|
||||
set(_jni_suffix "/${OpenCV_ARCH}")
|
||||
else()
|
||||
set(_jni_suffix "")
|
||||
endif()
|
||||
|
||||
ocv_update(OPENCV_BIN_INSTALL_PATH "${_prefix}bin")
|
||||
ocv_update(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${_prefix}samples")
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${_prefix}${_suffix}")
|
||||
ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH ".")
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH "include")
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH "etc")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH "samples")
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/licenses")
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "testdata")
|
||||
ocv_update(OPENCV_DOC_INSTALL_PATH "doc")
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH "java")
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "java${_jni_suffix}")
|
||||
ocv_update(OPENCV_JNI_BIN_INSTALL_PATH "${OPENCV_JNI_INSTALL_PATH}")
|
||||
|
||||
else() # UNIX
|
||||
|
||||
include(GNUInstallDirs)
|
||||
ocv_update(OPENCV_BIN_INSTALL_PATH "bin")
|
||||
ocv_update(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}")
|
||||
ocv_update(OPENCV_LIB_ARCHIVE_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}/opencv4/3rdparty")
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH "${OPENCV_LIB_INSTALL_PATH}/cmake/opencv4")
|
||||
ocv_update(OPENCV_INCLUDE_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/opencv4")
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/opencv4")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/samples")
|
||||
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/licenses/opencv4")
|
||||
ocv_update(OPENCV_TEST_DATA_INSTALL_PATH "${OPENCV_OTHER_INSTALL_PATH}/testdata")
|
||||
ocv_update(OPENCV_DOC_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/doc/opencv4")
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/java/opencv4")
|
||||
ocv_update(OPENCV_JNI_INSTALL_PATH "${OPENCV_JAR_INSTALL_PATH}")
|
||||
ocv_update(OPENCV_JNI_BIN_INSTALL_PATH "${OPENCV_JNI_INSTALL_PATH}")
|
||||
|
||||
endif()
|
||||
|
||||
ocv_update(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
if(INSTALL_TO_MANGLED_PATHS)
|
||||
foreach(v
|
||||
OPENCV_INCLUDE_INSTALL_PATH
|
||||
# file names include version (.so/.dll): OPENCV_LIB_INSTALL_PATH
|
||||
OPENCV_CONFIG_INSTALL_PATH
|
||||
OPENCV_3P_LIB_INSTALL_PATH
|
||||
OPENCV_SAMPLES_SRC_INSTALL_PATH
|
||||
OPENCV_DOC_INSTALL_PATH
|
||||
# JAR file name includes version: OPENCV_JAR_INSTALL_PATH
|
||||
OPENCV_TEST_DATA_INSTALL_PATH
|
||||
OPENCV_OTHER_INSTALL_PATH
|
||||
)
|
||||
string(REGEX REPLACE "opencv[0-9]*" "opencv-${OPENCV_VERSION}" ${v} "${${v}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# message(STATUS "Final install layout:")
|
||||
# ocv_cmake_dump_vars("OPENCV_.*_INSTALL_PATH")
|
Loading…
Reference in New Issue
Block a user