RTABMapConfig.cmake, guard from including stereoRectifyFisheye.h

This commit is contained in:
matlabbe
2026-07-09 04:23:24 +00:00
parent 0c0fd3b9ec
commit 206d1dc0e4
3 changed files with 18 additions and 1 deletions
+8
View File
@@ -1325,6 +1325,14 @@ install(EXPORT rtabmapTargets
#### ####
# Setup RTABMapConfig.cmake # Setup RTABMapConfig.cmake
#### ####
# OpenCV split calib3d into "calib"+"geometry" in version 5; record the
# components this build used so downstream find_package(RTABMap) requests a
# matching set for the same OpenCV major version.
IF(OpenCV_VERSION_MAJOR GREATER 4)
SET(CONF_OPENCV_COMPONENTS "core calib imgproc highgui stitching photo video geometry")
ELSE()
SET(CONF_OPENCV_COMPONENTS "core calib3d imgproc highgui stitching photo video")
ENDIF()
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+1 -1
View File
@@ -1,7 +1,7 @@
include(CMakeFindDependencyMacro) include(CMakeFindDependencyMacro)
# Mandatory dependencies # Mandatory dependencies
find_dependency(OpenCV COMPONENTS core calib3d imgproc highgui stitching photo video OPTIONAL_COMPONENTS aruco objdetect xfeatures2d nonfree gpu cudafeatures2d) find_dependency(OpenCV COMPONENTS @CONF_OPENCV_COMPONENTS@ OPTIONAL_COMPONENTS aruco objdetect xfeatures2d nonfree gpu cudafeatures2d)
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/RTABMap_guiTargets.cmake") if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/RTABMap_guiTargets.cmake")
find_dependency(PCL 1.7 COMPONENTS common io kdtree search surface filters registration sample_consensus segmentation visualization) find_dependency(PCL 1.7 COMPONENTS common io kdtree search surface filters registration sample_consensus segmentation visualization)
@@ -32,6 +32,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CORELIB_SRC_OPENCV_STEREORECTIFYFISHEYE_H_ #ifndef CORELIB_SRC_OPENCV_STEREORECTIFYFISHEYE_H_
#define CORELIB_SRC_OPENCV_STEREORECTIFYFISHEYE_H_ #define CORELIB_SRC_OPENCV_STEREORECTIFYFISHEYE_H_
// This header relies on the OpenCV C API (cvRodrigues2, cvProjectPoints2, ...)
// which was removed in OpenCV 5. Pull in only the version macros (available in
// all OpenCV versions) so we can fail early with a clear message rather than
// with cryptic errors from the includes below.
#include <opencv2/core/version.hpp>
#if CV_MAJOR_VERSION >= 5
#error "stereoRectifyFisheye.h is not supported with OpenCV 5 or later (it uses the removed OpenCV C API). Use cv::fisheye::stereoRectify() instead, or guard your include with '#if CV_MAJOR_VERSION < 5'."
#endif
#include <opencv2/calib3d/calib3d.hpp> #include <opencv2/calib3d/calib3d.hpp>
#if CV_MAJOR_VERSION >= 3 #if CV_MAJOR_VERSION >= 3
#include <opencv2/calib3d/calib3d_c.h> #include <opencv2/calib3d/calib3d_c.h>