2012-02-03 12:26:49 +01: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-19 22:30:13 +01:00
|
|
|
set(OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE TRUE)
|
2012-02-03 12:26:49 +01:00
|
|
|
else()
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE FALSE)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT OpenCV_CUDA_CC)
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_CUDA_CC_CONFIGCMAKE "\"\"")
|
2012-10-07 21:42:46 +02:00
|
|
|
set(OpenCV_CUDA_VERSION "")
|
2012-02-03 12:26:49 +01:00
|
|
|
else()
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_CUDA_CC_CONFIGCMAKE "${OpenCV_CUDA_CC}")
|
2012-10-07 21:42:46 +02:00
|
|
|
set(OpenCV_CUDA_VERSION ${CUDA_VERSION_STRING})
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ANDROID_NATIVE_API_LEVEL)
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE 0)
|
2012-02-03 12:26:49 +01:00
|
|
|
else()
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE "${ANDROID_NATIVE_API_LEVEL}")
|
|
|
|
endif()
|
|
|
|
|
2012-05-02 22:26:19 +02:00
|
|
|
if(CMAKE_GENERATOR MATCHES "Visual" OR CMAKE_GENERATOR MATCHES "Xcode")
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE TRUE)
|
|
|
|
else()
|
|
|
|
set(OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE FALSE)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
2012-06-27 15:52:29 +02:00
|
|
|
|
|
|
|
|
2012-03-11 08:00:22 +01:00
|
|
|
if(WIN32)
|
|
|
|
if(MINGW)
|
|
|
|
set(OPENCV_LINK_LIBRARY_SUFFIX ".dll.a")
|
|
|
|
else()
|
|
|
|
set(OPENCV_LINK_LIBRARY_SUFFIX ".lib")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-02-03 12:26:49 +01: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-19 22:30:13 +01:00
|
|
|
set(OPENCV_MODULES_CONFIGCMAKE ${OpenCV_LIB_COMPONENTS})
|
2012-02-03 12:26:49 +01:00
|
|
|
ocv_list_filterout(OpenCV_LIB_COMPONENTS "^opencv_")
|
|
|
|
if(OpenCV_LIB_COMPONENTS)
|
2012-02-19 22:30:13 +01:00
|
|
|
list(REMOVE_ITEM OPENCV_MODULES_CONFIGCMAKE ${OpenCV_LIB_COMPONENTS})
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
macro(ocv_generate_dependencies_map_configcmake suffix configuration)
|
2012-02-03 12:26:49 +01:00
|
|
|
set(OPENCV_DEPENDENCIES_MAP_${suffix} "")
|
|
|
|
set(OPENCV_PROCESSED_LIBS "")
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OPENCV_LIBS_TO_PROCESS ${OPENCV_MODULES_CONFIGCMAKE})
|
2012-02-03 12:26:49 +01:00
|
|
|
while(OPENCV_LIBS_TO_PROCESS)
|
|
|
|
list(GET OPENCV_LIBS_TO_PROCESS 0 __ocv_lib)
|
2012-02-06 12:30:59 +01:00
|
|
|
get_target_property(__libname ${__ocv_lib} LOCATION_${configuration})
|
|
|
|
get_filename_component(__libname "${__libname}" NAME)
|
2012-02-19 22:30:13 +01:00
|
|
|
|
2012-02-09 21:22:36 +01:00
|
|
|
if(WIN32)
|
2012-03-11 08:00:22 +01:00
|
|
|
string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "${OPENCV_LINK_LIBRARY_SUFFIX}" __libname "${__libname}")
|
2012-02-09 21:22:36 +01:00
|
|
|
endif()
|
2012-02-19 22:30:13 +01:00
|
|
|
|
2012-10-07 21:42:46 +02:00
|
|
|
if (CUDA_FOUND AND WIN32)
|
|
|
|
if(${__ocv_lib}_EXTRA_DEPS_${suffix})
|
|
|
|
list(REMOVE_ITEM ${__ocv_lib}_EXTRA_DEPS_${suffix} ${CUDA_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_npp_LIBRARY} ${CUDA_nvcuvid_LIBRARY} ${CUDA_nvcuvenc_LIBRARY})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2012-08-20 17:52:24 +02:00
|
|
|
string(REPLACE " " "\\ " __mod_deps "${${__ocv_lib}_MODULE_DEPS_${suffix}}")
|
|
|
|
string(REPLACE " " "\\ " __ext_deps "${${__ocv_lib}_EXTRA_DEPS_${suffix}}")
|
|
|
|
string(REPLACE "\"" "\\\"" __mod_deps "${__mod_deps}")
|
|
|
|
string(REPLACE "\"" "\\\"" __ext_deps "${__ext_deps}")
|
|
|
|
|
2012-10-07 21:42:46 +02:00
|
|
|
|
2012-02-06 12:30:59 +01:00
|
|
|
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_LIBNAME_${suffix} \"${__libname}\")\n")
|
2012-08-20 17:52:24 +02:00
|
|
|
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_DEPS_${suffix} ${__mod_deps})\n")
|
|
|
|
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_EXTRA_DEPS_${suffix} ${__ext_deps})\n")
|
2012-02-03 12:26:49 +01:00
|
|
|
|
|
|
|
list(APPEND OPENCV_PROCESSED_LIBS ${__ocv_lib})
|
|
|
|
list(APPEND OPENCV_LIBS_TO_PROCESS ${${__ocv_lib}_MODULE_DEPS_${suffix}})
|
|
|
|
list(REMOVE_ITEM OPENCV_LIBS_TO_PROCESS ${OPENCV_PROCESSED_LIBS})
|
|
|
|
endwhile()
|
|
|
|
unset(OPENCV_PROCESSED_LIBS)
|
|
|
|
unset(OPENCV_LIBS_TO_PROCESS)
|
|
|
|
unset(__ocv_lib)
|
2012-02-06 12:30:59 +01:00
|
|
|
unset(__libname)
|
2012-02-03 12:26:49 +01:00
|
|
|
endmacro()
|
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
ocv_generate_dependencies_map_configcmake(OPT Release)
|
|
|
|
ocv_generate_dependencies_map_configcmake(DBG Debug)
|
|
|
|
|
2012-02-03 12:26:49 +01:00
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------
|
|
|
|
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
|
|
|
|
# -------------------------------------------------------------------------------------------
|
2012-02-19 22:30:13 +01:00
|
|
|
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}\"")
|
2012-06-27 08:22:26 +02:00
|
|
|
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${3P_LIBRARY_OUTPUT_PATH}\"")
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "")
|
2012-02-06 12:30:59 +01:00
|
|
|
foreach(m ${OPENCV_MODULES_BUILD})
|
|
|
|
if(EXISTS "${OPENCV_MODULE_${m}_LOCATION}/include")
|
2012-02-19 22:30:13 +01:00
|
|
|
list(APPEND OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "${OPENCV_MODULE_${m}_LOCATION}/include")
|
2012-02-06 12:30:59 +01:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2012-02-27 13:49:00 +01: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()
|
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
2012-02-03 12:26:49 +01:00
|
|
|
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
|
2012-02-19 22:30:13 +01:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
2012-02-03 12:26:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
|
|
|
|
# -------------------------------------------------------------------------------------------
|
2012-06-27 15:52:29 +02:00
|
|
|
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
2012-06-27 08:22:26 +02:00
|
|
|
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)
|
2012-06-27 15:52:29 +02:00
|
|
|
string(REPLACE "OpenCV" "OpenCV-${OPENCV_VERSION}" OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "${OPENCV_3P_LIB_INSTALL_PATH}")
|
|
|
|
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE}\"")
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
2012-02-19 22:30:13 +01:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
2012-02-03 12:26:49 +01:00
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
#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)
|
|
|
|
if(INSTALL_TO_MANGLED_PATHS)
|
2012-06-27 15:52:29 +02:00
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/)
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}-${OPENCV_VERSION}/)
|
2012-02-03 12:26:49 +01:00
|
|
|
else()
|
2012-06-27 15:52:29 +02:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
|
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ANDROID)
|
2012-06-27 15:52:29 +02:00
|
|
|
install(FILES "${OpenCV_SOURCE_DIR}/android/android.toolchain.cmake" DESTINATION ${OPENCV_CONFIG_INSTALL_PATH}/)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
|
2012-02-19 22:30:13 +01:00
|
|
|
# --------------------------------------------------------------------------------------------
|
2012-02-03 12:26:49 +01:00
|
|
|
if(WIN32)
|
2012-02-19 22:30:13 +01:00
|
|
|
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}\"")
|
2012-06-27 08:22:26 +02:00
|
|
|
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
|
2012-02-19 22:30:13 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
|
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|