Opencv contrib SFM CERES ERROR!

There is a problem occurring during the installation process of opencv-contrib.
Ceres-solver is clearly installed.
However, errors related to Ceres persistently occur.

This is result of find ceres.

root@b1201fc87717:~/YOLOv8-TensorRT-CPP/libs/tensorrt-cpp-api/scripts# find / -name Ceres
/root/ceres/ceres-solver/build/CMakeFiles/Export/lib/cmake/Ceres
/usr/local/lib/cmake/Ceres
/usr/lib/cmake/Ceres

This is error

...
-- freetype2:   YES (ver 23.1.17)
-- harfbuzz:    YES (ver 2.6.4)
-- Julia not found. Not compiling Julia Bindings. 
-- Module opencv_ovis disabled because OGRE3D was not found
CMake Error at /usr/local/lib/cmake/Ceres/CeresConfig.cmake:89 (else):
  Flow control statements are not properly nested.
Call Stack (most recent call first):
  /root/YOLOv8-TensorRT-CPP/libs/tensorrt-cpp-api/scripts/opencv_contrib-4.8.0/modules/sfm/CMakeLists.txt:7 (find_package)


CMake Error at /root/YOLOv8-TensorRT-CPP/libs/tensorrt-cpp-api/scripts/opencv_contrib-4.8.0/modules/sfm/CMakeLists.txt:7 (find_package):
  find_package Error reading CMake code from
  "/usr/local/lib/cmake/Ceres/CeresConfig.cmake".


-- Configuring incomplete, errors occurred!

This is my build flags

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CERES_INCLUDE_DIR= /usr/lib/cmake/Ceres\
-D WITH_TBB=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=ON \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D BUILD_opencv_apps=OFF \
-D BUILD_opencv_python2=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${VERSION}/modules \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D WITH_FFMPEG=ON \
-D CUDNN_INCLUDE_DIR=/usr/local/cuda/include \
-D CUDNN_LIBRARY=/usr/local/cuda/lib64/libcudnn.so \

Please provide the cause of the problem and solutions. Thank you.

the sfm module asks for this dependency.

do you need the sfm module? it’s for Structure From Motion.

if you don’t need it, disable it through one of the appropriate cmake variables (I don’t know them by heart).