O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating a CMake script file

Before we start creating our source file, we are going to generate the CMakeLists.txt file to allow us to compile our project, structure it, and execute it. The following CMake script is simple and basic but enough to compile and generate the executable:

cmake_minimum_required (VERSION 3.0)PROJECT(Chapter4_Phototool)set (CMAKE_CXX_STANDARD 11)# Requires OpenCVFIND_PACKAGE( OpenCV 4.0.0 REQUIRED )MESSAGE("OpenCV version : ${OpenCV_VERSION}")include_directories(${OpenCV_INCLUDE_DIRS})link_directories(${OpenCV_LIB_DIR})ADD_EXECUTABLE(${PROJECT_NAME} main.cpp)TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OpenCV_LIBS})

The first line indicates the minimum CMake version required to generate our project, the second one sets ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required