Before we start creating our source file, we will generate the CMakeLists.txt
file that will allow us to compile our project, structure, and executable. The following cmake
script is simple and basic but enough to compile and generate the executable:
cmake_minimum_required (VERSION 2.6) cmake_policy(SET CMP0012 NEW) PROJECT(Chapter4_Phototool) # Requires OpenCV FIND_PACKAGE( OpenCV 3.0.0 REQUIRED ) include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIB_DIR}) ADD_EXECUTABLE( ${PROJECT_NAME} main.cpp ) TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${OpenCV_LIBS} )
Let's try to understand the script file.
The first line indicates the minimum cmake
version required to generate our project, and the second line sets the CMP0012
policy variable to allow you to identify numbers and Boolean constants and remove the CMake warning if it is not set:
cmake_minimum_required (VERSION 2.6) cmake_policy(SET CMP0012 NEW)
After these two lines, we define the project...