1 # cmake needs this line
2 cmake_minimum_required(VERSION 3.1)
4 if(NOT DEFINED EXAMPLE_NAME)
5 message(FATAL_ERROR "Invalid build script: missing EXAMPLE_NAME")
7 if(NOT DEFINED EXAMPLE_FILE)
8 message(FATAL_ERROR "Invalid build script: missing EXAMPLE_FILE")
11 file(TO_CMAKE_PATH "${EXAMPLE_FILE}" EXAMPLE_FILE)
12 message(STATUS "Project: ${EXAMPLE_NAME}")
13 message(STATUS "File : ${EXAMPLE_FILE}")
16 project(${EXAMPLE_NAME})
18 # Find OpenCV, you may need to set OpenCV_DIR variable
19 # to the absolute path to the directory containing OpenCVConfig.cmake file
20 # via the command line or GUI
21 find_package(OpenCV REQUIRED)
23 # If the package has been found, several variables will
24 # be set, you can find the full list with descriptions
25 # in the OpenCVConfig.cmake file.
26 # Print some message showing some of them
27 message(STATUS "OpenCV library status:")
28 message(STATUS " config: ${OpenCV_DIR}")
29 message(STATUS " version: ${OpenCV_VERSION}")
30 message(STATUS " libraries: ${OpenCV_LIBS}")
31 message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
33 # Declare the executable target built from your sources
34 add_executable(${EXAMPLE_NAME} "${EXAMPLE_FILE}")
36 # Link your application with OpenCV libraries
37 target_link_libraries(${EXAMPLE_NAME} PRIVATE ${OpenCV_LIBS})