mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
CMake: Detect when to set OPENCV_VER_23/OPENCV_VER_3
This commit is contained in:
parent
1a17808991
commit
654abdc5eb
@ -21,6 +21,7 @@
|
|||||||
# stitching
|
# stitching
|
||||||
# superres
|
# superres
|
||||||
# video
|
# video
|
||||||
|
# videoio
|
||||||
# videostab
|
# videostab
|
||||||
#
|
#
|
||||||
# Once done this will define:
|
# Once done this will define:
|
||||||
@ -30,33 +31,44 @@
|
|||||||
# component
|
# component
|
||||||
# OpenCV_LIBS - the paths to the OpenCV libraries for the requested
|
# OpenCV_LIBS - the paths to the OpenCV libraries for the requested
|
||||||
# component(s)
|
# component(s)
|
||||||
|
# OpenCV_VERSION_MAJOR- a "best guess" of the major version (X.x)
|
||||||
|
# OpenCV_VERSION_MINOR- a "best guess" of the minor version (x.X)
|
||||||
#
|
#
|
||||||
|
|
||||||
set(OpenCV_INCLUDE_DIRS)
|
set(OpenCV_INCLUDE_DIRS)
|
||||||
if(NOT OpenCV_V1_INCLUDE_DIR)
|
|
||||||
find_path(OpenCV_V1_INCLUDE_DIR
|
|
||||||
NAMES "cv.h"
|
|
||||||
PATH_SUFFIXES "opencv")
|
|
||||||
|
|
||||||
mark_as_advanced(OpenCV_V1_INCLUDE_DIR)
|
find_path(OpenCV_V1_INCLUDE_DIR
|
||||||
endif()
|
NAMES "cv.h"
|
||||||
|
PATH_SUFFIXES "opencv")
|
||||||
|
mark_as_advanced(OpenCV_V1_INCLUDE_DIR)
|
||||||
if(OpenCV_V1_INCLUDE_DIR)
|
if(OpenCV_V1_INCLUDE_DIR)
|
||||||
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V1_INCLUDE_DIR}")
|
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V1_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
# This is a wild guess:
|
||||||
|
set(OpenCV_VERSION_MAJOR 1)
|
||||||
|
set(OpenCV_VERSION_MINOR 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT OpenCV_V2_INCLUDE_DIR)
|
find_path(OpenCV_V2_INCLUDE_DIR "opencv2/core/version.hpp")
|
||||||
find_path(OpenCV_V2_INCLUDE_DIR "opencv2/core/core.hpp")
|
mark_as_advanced(OpenCV_V2_INCLUDE_DIR)
|
||||||
|
|
||||||
mark_as_advanced(OpenCV_V2_INCLUDE_DIR)
|
|
||||||
endif()
|
|
||||||
if(OpenCV_V2_INCLUDE_DIR)
|
if(OpenCV_V2_INCLUDE_DIR)
|
||||||
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V2_INCLUDE_DIR}")
|
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V2_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
file(STRINGS "${OpenCV_V2_INCLUDE_DIR}/opencv2/core/version.hpp"
|
||||||
|
_version_major REGEX "#define CV_VERSION_EPOCH")
|
||||||
|
file(STRINGS "${OpenCV_V2_INCLUDE_DIR}/opencv2/core/version.hpp"
|
||||||
|
_version_minor REGEX "#define CV_VERSION_MAJOR")
|
||||||
|
|
||||||
|
string(REGEX REPLACE "[^0-9]" "" OpenCV_VERSION_MAJOR "${_version_major}")
|
||||||
|
string(REGEX REPLACE "[^0-9]" "" OpenCV_VERSION_MINOR "${_version_minor}")
|
||||||
|
unset(_version_major)
|
||||||
|
unset(_version_minor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(OpenCV_LIBS)
|
set(OpenCV_LIBS)
|
||||||
foreach(_component calib3d contrib core features2d flann gpu highgui imgproc
|
foreach(_component calib3d contrib core features2d flann gpu highgui imgproc
|
||||||
legacy ml nonfree objdetect photo stitching superres video
|
legacy ml nonfree objdetect photo stitching superres video
|
||||||
videostab)
|
videoio videostab)
|
||||||
|
|
||||||
list(FIND OpenCV_FIND_COMPONENTS "${_component}" _index)
|
list(FIND OpenCV_FIND_COMPONENTS "${_component}" _index)
|
||||||
if(_index GREATER -1 OR _component STREQUAL "core")
|
if(_index GREATER -1 OR _component STREQUAL "core")
|
||||||
@ -76,4 +88,5 @@ unset(_component)
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(OpenCV HANDLE_COMPONENTS
|
find_package_handle_standard_args(OpenCV HANDLE_COMPONENTS
|
||||||
REQUIRED_VARS OpenCV_INCLUDE_DIRS OpenCV_LIBS)
|
REQUIRED_VARS OpenCV_INCLUDE_DIRS OpenCV_LIBS
|
||||||
|
OpenCV_VERSION_MAJOR OpenCV_VERSION_MINOR)
|
||||||
|
@ -474,7 +474,7 @@ package_status(EGL "EGL")
|
|||||||
#
|
#
|
||||||
|
|
||||||
# OpenCV
|
# OpenCV
|
||||||
find_package(OpenCV QUIET COMPONENTS core highgui)
|
find_package(OpenCV QUIET COMPONENTS core highgui OPTIONAL_COMPONENTS videoio)
|
||||||
|
|
||||||
package_option(OPENCV
|
package_option(OPENCV
|
||||||
"Enable support for OpenCV. This will be built into the 'vision' package."
|
"Enable support for OpenCV. This will be built into the 'vision' package."
|
||||||
@ -482,6 +482,13 @@ package_option(OPENCV
|
|||||||
|
|
||||||
package_status(OPENCV "OpenCV")
|
package_status(OPENCV "OpenCV")
|
||||||
|
|
||||||
|
if(OpenCV_VERSION_MAJOR GREATER_EQUAL 3)
|
||||||
|
set(OPENCV_VER_3 ON)
|
||||||
|
elseif(OpenCV_VERSION_MAJOR GREATER_EQUAL 2 AND
|
||||||
|
OpenCV_VERSION_MINOR GREATER_EQUAL 3)
|
||||||
|
set(OPENCV_VER_23 ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
# ARToolKit
|
# ARToolKit
|
||||||
find_package(ARToolKit QUIET)
|
find_package(ARToolKit QUIET)
|
||||||
|
|
||||||
|
@ -108,7 +108,6 @@
|
|||||||
|
|
||||||
/* Define if we have OpenCV installed and want to build for OpenCV. */
|
/* Define if we have OpenCV installed and want to build for OpenCV. */
|
||||||
#cmakedefine HAVE_OPENCV
|
#cmakedefine HAVE_OPENCV
|
||||||
#cmakedefine OPENCV_VER_23
|
|
||||||
|
|
||||||
/* Define if we have FFMPEG installed and want to build for FFMPEG. */
|
/* Define if we have FFMPEG installed and want to build for FFMPEG. */
|
||||||
#cmakedefine HAVE_FFMPEG
|
#cmakedefine HAVE_FFMPEG
|
||||||
|
@ -33,6 +33,12 @@ target_link_libraries(p3vision panda
|
|||||||
set_target_properties(p3vision PROPERTIES CXX_EXCEPTIONS ON)
|
set_target_properties(p3vision PROPERTIES CXX_EXCEPTIONS ON)
|
||||||
target_interrogate(p3vision ALL)
|
target_interrogate(p3vision ALL)
|
||||||
|
|
||||||
|
if(OPENCV_VER_3)
|
||||||
|
set_target_properties(p3vision PROPERTIES COMPILE_DEFINITIONS "OPENCV_VER_3")
|
||||||
|
elseif(OPENCV_VER_23)
|
||||||
|
set_target_properties(p3vision PROPERTIES COMPILE_DEFINITIONS "OPENCV_VER_23")
|
||||||
|
endif()
|
||||||
|
|
||||||
install(TARGETS p3vision
|
install(TARGETS p3vision
|
||||||
EXPORT Vision COMPONENT Vision
|
EXPORT Vision COMPONENT Vision
|
||||||
DESTINATION lib
|
DESTINATION lib
|
||||||
|
Loading…
x
Reference in New Issue
Block a user