Change the OpenCV_DIR to an Environment variable.

This commit is contained in:
ZhenyeLi 2024-11-12 12:06:03 +08:00
parent ccd034a14e
commit da14ed2c1d
2 changed files with 7 additions and 2 deletions

2
.gitignore vendored
View File

@ -363,4 +363,4 @@ MigrationBackup/
FodyWeavers.xsd
.idea
cmake-build-release-visual-studio
cmake-build-*

View File

@ -5,7 +5,12 @@ project(cotton_color)
set(CMAKE_CXX_STANDARD 17)
# OpenCV
set(OpenCV_DIR "E:/opencv4.10/opencv/build")
if(DEFINED ENV{OpenCV_DIR})
set(OpenCV_DIR ENV{OpenCV_DIR})
message(STATUS "OpenCV_DIR set from environment variable: ${OpenCV_DIR}")
else()
message(FATAL_ERROR "OpenCV_DIR is not set. Please set the OpenCV_DIR environment variable.")
endif()
# OpenCV
find_package(OpenCV REQUIRED)