CMakeLists.example.in 1.3 KB

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