Unknown CMake command "cmake_initialize_per_config_variable"
Hello. I'm trying to ask you a question because I got an error with cmake while preparing a project to use opencv.
cmake version: 3.22.1
cuda: 12.2
os: ubuntu 22.04
opencv: 4.8.0
The following error occurred when I entered "cmake .." in my_project/build directory.
CMake Error at /usr/share/cmake-3.22/Modules/FindCUDA.cmake:677 (cmake_initialize_per_config_variable): Unknown CMake command "cmake_initialize_per_config_variable".
Call Stack (most recent call first): /home/ubuntu/opencv-sources/opencv-4.8.0/build/OpenCVConfig.cmake:86 (find_package) /home/ubuntu/opencv-sources/opencv-4.8.0/build/OpenCVConfig.cmake:108 (find_host_package) CMakeLists.txt:9 (find_package)
The contents of CMakeListes.txt are as follows.
cmake_minimum_required(VERSION 3.0)
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
# Set the OpenCV directory
set(OpenCV_DIR "/home/ubuntu/opencv-sources/opencv-4.8.0/build")
# Find the OpenCV package
find_package(OpenCV REQUIRED)
project(${ProjectId} C CXX)
set (CMAKE_CXX_STANDARD 11)
file(GLOB SOURCES *.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
Opencv built its own source, and there were no issues with the build process.
What could be the cause of these problems? And How can i fix it?