mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
First pass at name mangling based on version number, to support
side by side installs of OpenCV2.3.0 OpenCV2.3.1 OpenCV2.4.x, etc...
This commit is contained in:
parent
d673197d01
commit
6259c9ac6a
@ -8,9 +8,11 @@
|
||||
# - OCT-2008: Initial version <joseluisblancoc@gmail.com>
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
cmake_minimum_required(VERSION 2.4)
|
||||
project(OpenCV)
|
||||
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
|
||||
set(OPENCV_INCLUDE_PREFIX include)
|
||||
# Add these standard paths to the search paths for FIND_LIBRARY
|
||||
# to find libraries from these locations first
|
||||
if(UNIX)
|
||||
@ -49,10 +51,6 @@ if (WIN32 AND ${CMAKE_GENERATOR} MATCHES "(MinGW)|(MSYS)" AND NOT ANDROID)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
|
||||
project(OpenCV)
|
||||
cmake_minimum_required(VERSION 2.4)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
@ -104,7 +102,7 @@ endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# Current version number:
|
||||
# ----------------------------------------------------------------------------
|
||||
set(OPENCV_VERSION "2.3.0")
|
||||
set(OPENCV_VERSION "2.3.1")
|
||||
|
||||
string(REGEX MATCHALL "[0-9]+" OPENCV_VERSION_PARTS "${OPENCV_VERSION}")
|
||||
|
||||
@ -125,6 +123,14 @@ else()
|
||||
set(OPENCV_DEBUG_POSTFIX)
|
||||
endif()
|
||||
|
||||
#name mangling
|
||||
if(UNIX)
|
||||
option(OPENCV_MANGLED_INSTALL_PATHS "Enables mangled install paths, that help with side by side installs" False)
|
||||
if(OPENCV_MANGLED_INSTALL_PATHS)
|
||||
set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Build static or dynamic libs?
|
||||
# Default: dynamic libraries
|
||||
@ -1151,7 +1157,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINA
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
|
||||
# -------------------------------------------------------------------------------------------
|
||||
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/include/opencv" "\${OpenCV_INSTALL_PATH}/include\"")
|
||||
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}\"")
|
||||
|
||||
|
||||
set(CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE "")
|
||||
if(ANDROID)
|
||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/libs/\${ARMEABI_NDK_NAME}\"")
|
||||
@ -1161,12 +1169,24 @@ else()
|
||||
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
|
||||
endif()
|
||||
|
||||
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/unix-install/\"" OUTPUT_VARIABLE RET_VAL)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
||||
|
||||
if(UNIX)
|
||||
# For a command "FIND_PACKAGE(FOO)", CMake will look at the directory /usr/share|lib/FOO/FOOConfig.cmake, so:
|
||||
#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(OPENCV_MANGLED_INSTALL_PATHS)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake DESTINATION share/OpenCV-${OPENCV_VERSION}/)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION share/OpenCV-${OPENCV_VERSION}/)
|
||||
else()
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" DESTINATION share/OpenCV/)
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
@ -1246,8 +1266,8 @@ endif(ANDROID)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix "\${prefix}")
|
||||
set(libdir "\${exec_prefix}/lib")
|
||||
set(includedir "\${prefix}/include")
|
||||
set(VERSION ${OPENCV_VERSION})
|
||||
set(includedir "\${prefix}/${OPENCV_INCLUDE_PREFIX}")
|
||||
set(VERSION ${OPENCV_VERSION})
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencv.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/opencv.pc" @ONLY IMMEDIATE)
|
||||
|
||||
|
14
OpenCVConfig-version.cmake.in
Normal file
14
OpenCVConfig-version.cmake.in
Normal file
@ -0,0 +1,14 @@
|
||||
SET(OpenCV_VERSION @OPENCV_VERSION@)
|
||||
SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@)
|
||||
SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@)
|
||||
SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
|
||||
set(PACKAGE_VERSION OpenCV_VERSION)
|
||||
if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL ${OpenCV_VERSION_MAJOR})
|
||||
set(PACKAGE_VERSION_COMPATIBLE True) # compatible with any version @OPENCV_VERSION_MAJOR@.x.x
|
||||
if("${PACKAGE_FIND_VERSION_MINOR}" EQUAL ${OpenCV_VERSION_MINOR})
|
||||
set(PACKAGE_VERSION_COMPATIBLE True) # compatible with any version @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.x
|
||||
if("${PACKAGE_FIND_VERSION_PATCH}" EQUAL ${OpenCV_VERSION_PATCH})
|
||||
set(PACKAGE_VERSION_EXACT True) # exact match for patch @OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
@ -61,28 +61,42 @@ SET(OpenCV_LIB_DIR @CMAKE_LIB_DIRS_CONFIGCMAKE@)
|
||||
LINK_DIRECTORIES(${OpenCV_LIB_DIR})
|
||||
|
||||
# ====================================================================
|
||||
# Link libraries: e.g. opencv_core220.so, opencv_imgproc220d.lib, etc...
|
||||
# Link libraries: e.g. libopencv_core.so, opencv_imgproc220d.lib, etc...
|
||||
# ====================================================================
|
||||
#libraries order is very important because linker from Android NDK is one-pass linker
|
||||
SET(OpenCV_LIB_COMPONENTS opencv_contrib opencv_legacy opencv_objdetect opencv_calib3d opencv_features2d opencv_video opencv_highgui opencv_ml opencv_imgproc opencv_flann opencv_core )
|
||||
|
||||
#libraries order is very important because linker from Android NDK is one-pass linker
|
||||
if(NOT ANDROID)
|
||||
LIST(INSERT OpenCV_LIB_COMPONENTS 0 opencv_gpu)
|
||||
ELSEIF(NOT OpenCV_SHARED)
|
||||
LIST(APPEND OpenCV_LIB_COMPONENTS opencv_androidcamera)
|
||||
endif()
|
||||
|
||||
if(@OPENCV_MANGLED_INSTALL_PATHS@)
|
||||
#be explicit about the library names.
|
||||
set(OpenCV_LIB_COMPONENTS_ )
|
||||
foreach( CVLib ${OpenCV_LIB_COMPONENTS})
|
||||
list(APPEND OpenCV_LIB_COMPONENTS_ ${OpenCV_LIB_DIR}/lib${CVLib}.so.@OPENCV_VERSION@ )
|
||||
endforeach()
|
||||
set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
|
||||
endif()
|
||||
|
||||
SET(OpenCV_LIBS "")
|
||||
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
|
||||
# CMake>=2.6 supports the notation "debug XXd optimized XX"
|
||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
|
||||
# Modern CMake:
|
||||
SET(OpenCV_LIBS ${OpenCV_LIBS} debug ${__CVLIB}@OPENCV_DLLVERSION@@OPENCV_DEBUG_POSTFIX@ optimized ${__CVLIB}@OPENCV_DLLVERSION@)
|
||||
else()
|
||||
# Old CMake:
|
||||
SET(OpenCV_LIBS ${OpenCV_LIBS} ${__CVLIB}@OPENCV_DLLVERSION@)
|
||||
endif()
|
||||
endforeach()
|
||||
if(WIN32)
|
||||
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
|
||||
# CMake>=2.6 supports the notation "debug XXd optimized XX"
|
||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
|
||||
# Modern CMake:
|
||||
SET(OpenCV_LIBS ${OpenCV_LIBS} debug ${__CVLIB}@OPENCV_DLLVERSION@@OPENCV_DEBUG_POSTFIX@ optimized ${__CVLIB}@OPENCV_DLLVERSION@)
|
||||
else()
|
||||
# Old CMake:
|
||||
SET(OpenCV_LIBS ${OpenCV_LIBS} ${__CVLIB}@OPENCV_DLLVERSION@)
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
|
||||
SET(OpenCV_LIBS ${OpenCV_LIBS} ${__CVLIB})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# ==============================================================
|
||||
# Extra include directories, needed by OpenCV 2 new structure
|
||||
|
@ -101,7 +101,7 @@ macro(define_opencv_module name)
|
||||
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
|
||||
|
||||
install(FILES ${lib_hdrs}
|
||||
DESTINATION include/opencv2/${name}
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
|
||||
COMPONENT main)
|
||||
|
||||
if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
|
@ -1,8 +1,9 @@
|
||||
file(GLOB old_hdrs "opencv/*.h*")
|
||||
install(FILES ${old_hdrs}
|
||||
DESTINATION include/opencv
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv
|
||||
COMPONENT main)
|
||||
install(FILES "opencv2/opencv.hpp"
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2
|
||||
COMPONENT main)
|
||||
|
||||
install(FILES "opencv2/opencv.hpp"
|
||||
DESTINATION include/opencv2
|
||||
COMPONENT main)
|
||||
|
||||
|
@ -153,15 +153,15 @@ install(TARGETS ${the_target}
|
||||
ARCHIVE DESTINATION lib COMPONENT main)
|
||||
|
||||
install(FILES ${lib_hdrs}
|
||||
DESTINATION include/opencv2/${name}
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
|
||||
COMPONENT main)
|
||||
|
||||
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
|
||||
DESTINATION include/opencv2/${name}
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
|
||||
COMPONENT main)
|
||||
|
||||
#install(FILES ${lib_device_hdrs}
|
||||
# DESTINATION include/opencv2/${name}/device
|
||||
# DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}/device
|
||||
# COMPONENT main)
|
||||
|
||||
|
||||
|
@ -366,7 +366,7 @@ install(TARGETS ${the_target}
|
||||
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
|
||||
|
||||
install(FILES ${highgui_ext_hdrs}
|
||||
DESTINATION include/opencv2/highgui
|
||||
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/highgui
|
||||
COMPONENT main)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user