-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
133 lines (109 loc) · 3.68 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_CXX_STANDARD 20)
project(grabthecam VERSION 0.1)
find_package(OpenCV REQUIRED)
find_package(RapidJSON REQUIRED)
option(ADD_GRABTHECAM_FARSHOW_DEMO "Adds a target for grabthecam-farshow integration demo" OFF)
option(BUILD_TESTS "Enables building of testing binaries" OFF)
set(INCLUDE_DIRECTORIES
${OpenCV_INCLUDE_DIRS}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third-party/include/>
$<INSTALL_INTERFACE:include>
)
include_directories(${INCLUDE_DIRECTORIES})
add_library(${PROJECT_NAME} SHARED
src/mmapbuffer.cpp
src/frameconverter.cpp
src/frameconverters/yuv2bgrconverter.cpp
src/frameconverters/packedformats2rgbconverter.cpp
src/frameconverters/bayer2bgrconverter.cpp
src/frameconverters/anyformat2bgrconverter.cpp
src/utils.cpp
src/cameracapture.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRECTORIES})
target_link_libraries(${PROJECT_NAME} PUBLIC
v4l2
${OpenCV_LIBS}
)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION}
)
add_executable(${PROJECT_NAME}-demo
src/example.cpp
)
target_include_directories(${PROJECT_NAME}-demo PUBLIC ${INCLUDE_DIRECTORIES})
target_link_libraries(${PROJECT_NAME}-demo PRIVATE
${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}-demo PUBLIC
v4l2
${OpenCV_LIBS}
)
if(BUILD_TESTS)
add_executable(${PROJECT_NAME}-test-frame-fetch
tests/test_frame_fetch.cpp
)
target_include_directories(${PROJECT_NAME}-test-frame-fetch PUBLIC ${INCLUDE_DIRECTORIES})
target_link_libraries(${PROJECT_NAME}-test-frame-fetch PRIVATE
${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}-test-frame-fetch PUBLIC
v4l2
${OpenCV_LIBS}
)
endif()
if(ADD_GRABTHECAM_FARSHOW_DEMO)
find_package(farshow QUIET)
if(NOT farshow_FOUND)
cmake_policy(SET CMP0002 OLD)
message("farshow not found - building it")
include(FetchContent)
FetchContent_Declare(farshow
GIT_REPOSITORY https://github.com/antmicro/farshow
GIT_TAG main
)
FetchContent_MakeAvailable(farshow)
endif()
add_executable(${PROJECT_NAME}-farshow-streamer
src/farshow-streamer-example.cpp
)
target_include_directories(${PROJECT_NAME}-farshow-streamer PUBLIC ${INCLUDE_DIRECTORIES})
target_link_libraries(${PROJECT_NAME}-farshow-streamer PUBLIC
${PROJECT_NAME}
v4l2
farshow-connection
${OpenCV_LIBS}
)
install(TARGETS ${PROJECT_NAME}-farshow-streamer)
endif()
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-demo
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
configure_file(
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY
)
export(
TARGETS ${PROJECT_NAME} FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
)
install(
EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake/${PROJECT_NAME}
)
install(
DIRECTORY include/grabthecam/ DESTINATION include/grabthecam/
)
install(
FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION lib/cmake/${PROJECT_NAME}
)
add_custom_target(format
COMMAND bash -c "clang-tidy -format-style=file \$(find ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/include | egrep '(*hpp|*cpp)' | tr '\\n' ' ') -p ${CMAKE_BINARY_DIR} -fix"
COMMAND bash -c "clang-format --style=file -i \$(find ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/include | egrep '(*hpp|*cpp)' | tr '\\n' ' ')"
VERBATIM
)