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()
|
|
|
|
|
|
|
|
if(NOT OpenCV_CUDA_CC)
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_CUDA_CC_CONFIGCMAKE "\"\"")
|
2012-10-08 03:42:46 +08:00
|
|
|
set(OpenCV_CUDA_VERSION "")
|
2012-02-03 19:26:49 +08:00
|
|
|
else()
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_CUDA_CC_CONFIGCMAKE "${OpenCV_CUDA_CC}")
|
2012-10-08 03:42:46 +08:00
|
|
|
set(OpenCV_CUDA_VERSION ${CUDA_VERSION_STRING})
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ANDROID_NATIVE_API_LEVEL)
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE 0)
|
2012-02-03 19:26:49 +08:00
|
|
|
else()
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE "${ANDROID_NATIVE_API_LEVEL}")
|
|
|
|
endif()
|
|
|
|
|
2012-05-03 04:26:19 +08:00
|
|
|
if(CMAKE_GENERATOR MATCHES "Visual" OR CMAKE_GENERATOR MATCHES "Xcode")
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE TRUE)
|
|
|
|
else()
|
|
|
|
set(OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE FALSE)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
2012-06-27 21:52:29 +08:00
|
|
|
|
|
|
|
|
2012-03-11 15:00:22 +08:00
|
|
|
if(WIN32)
|
|
|
|
if(MINGW)
|
|
|
|
set(OPENCV_LINK_LIBRARY_SUFFIX ".dll.a")
|
|
|
|
else()
|
|
|
|
set(OPENCV_LINK_LIBRARY_SUFFIX ".lib")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-02-03 19:26:49 +08:00
|
|
|
|
|
|
|
#build list of modules available for the OpenCV user
|
|
|
|
set(OpenCV_LIB_COMPONENTS "")
|
|
|
|
foreach(m ${OPENCV_MODULES_PUBLIC})
|
|
|
|
list(INSERT OpenCV_LIB_COMPONENTS 0 ${${m}_MODULE_DEPS_OPT} ${m})
|
|
|
|
endforeach()
|
|
|
|
ocv_list_unique(OpenCV_LIB_COMPONENTS)
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OPENCV_MODULES_CONFIGCMAKE ${OpenCV_LIB_COMPONENTS})
|
2012-02-03 19:26:49 +08:00
|
|
|
ocv_list_filterout(OpenCV_LIB_COMPONENTS "^opencv_")
|
|
|
|
if(OpenCV_LIB_COMPONENTS)
|
2012-02-20 05:30:13 +08:00
|
|
|
list(REMOVE_ITEM OPENCV_MODULES_CONFIGCMAKE ${OpenCV_LIB_COMPONENTS})
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
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-20 05:30:13 +08:00
|
|
|
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "")
|
2012-02-06 19:30:59 +08:00
|
|
|
foreach(m ${OPENCV_MODULES_BUILD})
|
|
|
|
if(EXISTS "${OPENCV_MODULE_${m}_LOCATION}/include")
|
2012-02-20 05:30:13 +08:00
|
|
|
list(APPEND OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "${OPENCV_MODULE_${m}_LOCATION}/include")
|
2012-02-06 19:30:59 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2012-02-27 20:49:00 +08:00
|
|
|
if(ANDROID AND NOT BUILD_SHARED_LIBS AND HAVE_TBB)
|
|
|
|
#export TBB headers location because static linkage of TBB might be troublesome if application wants to use TBB itself
|
|
|
|
list(APPEND OpenCV2_INCLUDE_DIRS_CONFIGCMAKE ${TBB_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
|
2013-10-25 00:01:29 +08:00
|
|
|
set(modules_file_suffix "")
|
|
|
|
if(ANDROID)
|
2013-10-25 23:10:13 +08:00
|
|
|
# the REPLACE here is needed, because OpenCVModules_armeabi.cmake includes
|
|
|
|
# OpenCVModules_armeabi-*.cmake, which would match OpenCVModules_armeabi-v7a*.cmake.
|
|
|
|
string(REPLACE - _ modules_file_suffix "_${ANDROID_NDK_ABI_NAME}")
|
2013-10-25 00:01:29 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules${modules_file_suffix}.cmake")
|
2013-10-16 03:05:40 +08:00
|
|
|
|
2014-05-06 23:14:20 +08:00
|
|
|
if(TARGET ippicv)
|
|
|
|
set(USE_IPPICV TRUE)
|
|
|
|
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH})
|
|
|
|
else()
|
|
|
|
set(USE_IPPICV FALSE)
|
|
|
|
set(INSTALL_PATH_RELATIVE_IPPICV "non-existed-path")
|
|
|
|
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"
|
|
|
|
# -------------------------------------------------------------------------------------------
|
2012-06-27 21:52:29 +08:00
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
2015-03-13 00:14:14 +08:00
|
|
|
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2013-10-25 00:01:29 +08:00
|
|
|
if(UNIX) # ANDROID configuration is created here also
|
2012-02-03 19:26:49 +08:00
|
|
|
#http://www.vtk.org/Wiki/CMake/Tutorials/Packaging reference
|
|
|
|
# For a command "find_package(<name> [major[.minor]] [EXACT] [REQUIRED|QUIET])"
|
|
|
|
# cmake will look in the following dir on unix:
|
|
|
|
# <prefix>/(share|lib)/cmake/<name>*/ (U)
|
|
|
|
# <prefix>/(share|lib)/<name>*/ (U)
|
|
|
|
# <prefix>/(share|lib)/<name>*/(cmake|CMake)/ (U)
|
2014-05-06 23:14:20 +08:00
|
|
|
if(USE_IPPICV)
|
2015-03-13 00:14:14 +08:00
|
|
|
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}/" ${IPPICV_INSTALL_PATH})
|
2014-05-06 23:14:20 +08:00
|
|
|
endif()
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" @ONLY)
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" @ONLY)
|
2015-03-13 00:14:14 +08:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/ COMPONENT dev)
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/ COMPONENT dev)
|
|
|
|
install(EXPORT OpenCVModules DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/ FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ANDROID)
|
2014-01-17 20:30:31 +08:00
|
|
|
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)
|
2012-02-20 05:30:13 +08:00
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/include\" \"\${OpenCV_CONFIG_PATH}/include/opencv\"")
|
|
|
|
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
|
|
|
|
|
|
|
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
|
2014-05-06 23:14:20 +08:00
|
|
|
if(USE_IPPICV)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}lib" ${IPPICV_INSTALL_PATH})
|
|
|
|
else()
|
|
|
|
file(RELATIVE_PATH INSTALL_PATH_RELATIVE_IPPICV "${CMAKE_INSTALL_PREFIX}/${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" ${IPPICV_INSTALL_PATH})
|
|
|
|
endif()
|
|
|
|
endif()
|
2014-01-29 23:34:02 +08:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" @ONLY)
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY)
|
2014-09-30 17:36:37 +08:00
|
|
|
if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" COMPONENT dev)
|
|
|
|
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
|
|
|
else()
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" COMPONENT dev)
|
|
|
|
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
|
|
|
endif()
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT dev)
|
|
|
|
install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/" COMPONENT dev)
|
|
|
|
else ()
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" COMPONENT dev)
|
|
|
|
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/opencv-${OPENCV_VERSION}" COMPONENT dev)
|
|
|
|
endif ()
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|