Created
January 8, 2024 08:45
-
-
Save paulobunga/d39d47a8d6eb00991d7fe8bc33255a80 to your computer and use it in GitHub Desktop.
CMake Setup for CLion Windows OpenCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.25) | |
project(ProjectName) | |
set(CMAKE_CXX_STANDARD 11) | |
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) | |
set(OpenCV_DIR "C:/tools/opencv/build/x64/vc16/lib") | |
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") | |
find_package(OpenCV REQUIRED) | |
include_directories(${OpenCV_INCLUDE_DIRS}) | |
add_executable(ProjectName main.cpp) | |
target_link_libraries(ProjectName ${OpenCV_LIBS}) |
Download OpenCV from the official website’s download page, extract it to your preferred location, and ensure CMake is installed and added to your system's PATH.
Additionally, don't forget to add OpenCV to your PATH.
i.e C:\tools\opencv\build\x64\vc16\bin and C:\Program Files\CMake\bin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Paul, I'm trying to setup a project that uses OpenCV and I've modified my CMakeList to align with yours, but I'm still getting
fatal error C1083: Cannot open include file: 'core.hpp': No such file or directory
, I'm wondering if there's anything else I need to configure to get OpenCV to work? I selected Visual Studio for the default Toolchain and installed OpenCV with Chocolatey. Thank you so much!