2012-02-03 19:26:49 +08:00
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Installation for CMake Module: OpenCVConfig.cmake
|
|
|
|
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
|
|
|
|
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use with "make install"
|
|
|
|
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
|
|
|
|
# -------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if(INSTALL_TO_MANGLED_PATHS)
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE TRUE)
|
2012-02-03 19:26:49 +08:00
|
|
|
else()
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE FALSE)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
2016-01-11 22:54:14 +08:00
|
|
|
if(HAVE_CUDA)
|
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-CUDA.cmake.in" CUDA_CONFIGCMAKE @ONLY)
|
2012-02-20 05:30:13 +08:00
|
|
|
endif()
|
|
|
|
|
2016-01-11 22:54:14 +08:00
|
|
|
if(ANDROID)
|
|
|
|
if(NOT ANDROID_NATIVE_API_LEVEL)
|
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE 0)
|
2012-03-11 15:00:22 +08:00
|
|
|
else()
|
2016-01-11 22:54:14 +08:00
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE "${ANDROID_NATIVE_API_LEVEL}")
|
2012-03-11 15:00:22 +08:00
|
|
|
endif()
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-ANDROID.cmake.in" ANDROID_CONFIGCMAKE @ONLY)
|
2012-03-11 15:00:22 +08:00
|
|
|
endif()
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2016-01-11 22:54:14 +08:00
|
|
|
set(OPENCV_MODULES_CONFIGCMAKE ${OPENCV_MODULES_PUBLIC})
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2013-02-27 16:41:33 +08:00
|
|
|
if(BUILD_FAT_JAVA_LIB AND HAVE_opencv_java)
|
|
|
|
list(APPEND OPENCV_MODULES_CONFIGCMAKE opencv_java)
|
|
|
|
endif()
|
|
|
|
|
2012-02-03 19:26:49 +08:00
|
|
|
# -------------------------------------------------------------------------------------------
|
|
|
|
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
|
|
|
|
# -------------------------------------------------------------------------------------------
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2012-02-06 19:30:59 +08:00
|
|
|
foreach(m ${OPENCV_MODULES_BUILD})
|
|
|
|
if(EXISTS "${OPENCV_MODULE_${m}_LOCATION}/include")
|
2016-01-11 22:54:14 +08:00
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "${OpenCV_INCLUDE_DIRS_CONFIGCMAKE} \"${OPENCV_MODULE_${m}_LOCATION}/include\"")
|
2012-02-06 19:30:59 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-01-11 22:54:14 +08:00
|
|
|
export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules.cmake")
|
2013-10-25 00:01:29 +08:00
|
|
|
|
2016-01-11 22:54:14 +08:00
|
|
|
if(TARGET ippicv AND NOT BUILD_SHARED_LIBS)
|
2014-05-06 23:14:20 +08:00
|
|
|
set(USE_IPPICV TRUE)
|
2017-04-25 21:48:50 +08:00
|
|
|
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPICV_LOCATION_PATH}")
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
|
2014-05-06 23:14:20 +08:00
|
|
|
else()
|
|
|
|
set(USE_IPPICV FALSE)
|
|
|
|
endif()
|
|
|
|
|
2017-04-25 21:48:50 +08:00
|
|
|
if(TARGET ippiw AND NOT BUILD_SHARED_LIBS AND IPPIW_INSTALL_PATH)
|
|
|
|
set(USE_IPPIW TRUE)
|
|
|
|
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPIW_LOCATION_PATH}")
|
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
|
|
|
|
else()
|
|
|
|
set(USE_IPPIW FALSE)
|
|
|
|
endif()
|
|
|
|
|
2014-01-29 23:34:02 +08:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
|
2012-02-03 19:26:49 +08:00
|
|
|
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
|
2014-01-29 23:34:02 +08:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
|
2012-02-03 19:26:49 +08:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
|
|
|
|
# -------------------------------------------------------------------------------------------
|
2016-01-11 22:54:14 +08:00
|
|
|
file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}/" ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"")
|
|
|
|
|
|
|
|
if(USE_IPPICV)
|
2017-04-25 21:48:50 +08:00
|
|
|
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
|
|
|
|
endif()
|
2017-04-25 21:48:50 +08:00
|
|
|
if(USE_IPPIW)
|
|
|
|
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPIW_INSTALL_PATH}")
|
|
|
|
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
|
|
|
|
endif()
|
2016-01-11 22:54:14 +08:00
|
|
|
|
|
|
|
function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
|
|
|
|
ocv_path_join(__install_nested "${OPENCV_CONFIG_INSTALL_PATH}" "${NESTED_PATH}")
|
|
|
|
ocv_path_join(__tmp_nested "${TMP_DIR}" "${NESTED_PATH}")
|
|
|
|
|
|
|
|
file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${__install_nested}" "${CMAKE_INSTALL_PREFIX}/")
|
|
|
|
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${TMP_DIR}/OpenCVConfig-version.cmake" @ONLY)
|
|
|
|
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${__tmp_nested}/OpenCVConfig.cmake" @ONLY)
|
|
|
|
install(EXPORT OpenCVModules DESTINATION "${__install_nested}" FILE OpenCVModules.cmake COMPONENT dev)
|
|
|
|
install(FILES
|
|
|
|
"${TMP_DIR}/OpenCVConfig-version.cmake"
|
|
|
|
"${__tmp_nested}/OpenCVConfig.cmake"
|
2016-06-22 21:12:52 +08:00
|
|
|
DESTINATION "${__install_nested}" COMPONENT dev)
|
2016-01-11 22:54:14 +08:00
|
|
|
|
|
|
|
if(ROOT_NAME)
|
|
|
|
# Root config file
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/${ROOT_NAME}" "${TMP_DIR}/OpenCVConfig.cmake" @ONLY)
|
|
|
|
install(FILES
|
|
|
|
"${TMP_DIR}/OpenCVConfig-version.cmake"
|
|
|
|
"${TMP_DIR}/OpenCVConfig.cmake"
|
2016-06-22 21:12:52 +08:00
|
|
|
DESTINATION "${OPENCV_CONFIG_INSTALL_PATH}" COMPONENT dev)
|
2014-05-06 23:14:20 +08:00
|
|
|
endif()
|
2016-01-11 22:54:14 +08:00
|
|
|
endfunction()
|
|
|
|
|
2017-11-28 17:53:40 +08:00
|
|
|
if((CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" OR UNIX) AND NOT ANDROID)
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "" "")
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ANDROID)
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_gen_config("${CMAKE_BINARY_DIR}/unix-install" "abi-${ANDROID_NDK_ABI_NAME}" "OpenCVConfig.root-ANDROID.cmake.in")
|
|
|
|
install(FILES "${OpenCV_SOURCE_DIR}/platforms/android/android.toolchain.cmake" DESTINATION "${OPENCV_CONFIG_INSTALL_PATH}" COMPONENT dev)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
|
2012-02-20 05:30:13 +08:00
|
|
|
# --------------------------------------------------------------------------------------------
|
2012-02-03 19:26:49 +08:00
|
|
|
if(WIN32)
|
2016-01-11 22:54:14 +08:00
|
|
|
if(CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
2014-09-30 17:36:37 +08:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2016-01-11 22:54:14 +08:00
|
|
|
set(_lib_suffix "lib")
|
2014-09-30 17:36:37 +08:00
|
|
|
else()
|
2016-01-11 22:54:14 +08:00
|
|
|
set(_lib_suffix "staticlib")
|
2014-09-30 17:36:37 +08:00
|
|
|
endif()
|
2016-01-11 22:54:14 +08:00
|
|
|
ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "${OpenCV_INSTALL_BINARIES_PREFIX}${_lib_suffix}" "OpenCVConfig.root-WIN32.cmake.in")
|
|
|
|
else()
|
|
|
|
ocv_gen_config("${CMAKE_BINARY_DIR}/win-install" "" "")
|
|
|
|
endif()
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|