-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
52 lines (41 loc) · 1.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required(VERSION 3.6)
project(
SimpleCam
DESCRIPTION "A small and documented example application for libcamera"
LANGUAGES CXX)
# Generate compile_commands.json
#set(CMAKE_EXPORT_COMPILE_COMMANDS
# ON
# CACHE INTERNAL "")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS
"-Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -Wno-unused-parameter"
)
find_package(PkgConfig)
pkg_check_modules(LIBCAMERA REQUIRED IMPORTED_TARGET libcamera)
message(STATUS "libcamera library found:")
message(STATUS " version: ${LIBCAMERA_VERSION}")
message(STATUS " libraries: ${LIBCAMERA_LINK_LIBRARIES}")
message(STATUS " include path: ${LIBCAMERA_INCLUDE_DIRS}")
# libevent is used specifically by simple-cam as its event loop. Applications
# may use a different event handling implementation.
pkg_check_modules(LIBEVENT REQUIRED IMPORTED_TARGET libevent_pthreads)
message(STATUS "libevent_pthreads library found:")
message(STATUS " version: ${LIBEVENT_VERSION}")
message(STATUS " libraries: ${LIBEVENT_LINK_LIBRARIES}")
message(STATUS " include path: ${LIBEVENT_INCLUDE_DIRS}")
find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui)
if(OpenCV_FOUND)
message(STATUS "OpenCV library found: ${OpenCV_FOUND}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "OpenCV not found")
endif()
include_directories(${CMAKE_SOURCE_DIR} ${LIBCAMERA_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
add_executable(simple-cam simple-cam.cpp event_loop.cpp image.cpp)
target_link_libraries(simple-cam PkgConfig::LIBEVENT)
target_link_libraries(simple-cam PkgConfig::LIBCAMERA)
target_link_libraries(simple-cam ${OpenCV_LIBS})