-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
210 lines (175 loc) · 6.4 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Copyright (C) 2023 Electronic Arts, Inc. All rights reserved.
cmake_minimum_required (VERSION 3.21.0)
project(iris VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/)
# ---------------------------------------------------------------------------------------
# Options
# ---------------------------------------------------------------------------------------
option(BUILD_TESTS "Build library tests" OFF)
option(BUILD_EXAMPLE_APP "Build Iris example console application" OFF)
option(EXPORT_IRIS "Export and install library" ON)
option(BUILD_SHARED_LIBS "Build iris as a shared library" OFF)
option(BUILD_COVERAGE "Builds code coverage target" OFF)
option(PROFILER "Enable profiling" OFF)
if (BUILD_COVERAGE AND NOT UNIX)
set(BUILD_COVERAGE OFF)
message("Code coverage can only be built in Linux systems")
endif()
# ---------------------------------------------------------------------------------------
# Iris Library
# ---------------------------------------------------------------------------------------
set(PUBLIC_HEADERS
"include/iris/VideoAnalyser.h"
"include/iris/Configuration.h"
"include/iris/Log.h"
"include/iris/Result.h"
"include/iris/TotalFlashIncidents.h"
"include/iris/ScopeProfiler.h"
)
source_group("Public header files" FILES ${PUBLIC_HEADERS})
set(SOURCE_FILES
"src/VideoAnalyser.cpp"
"src/FrameRgbConverter.cpp"
"src/Flash.cpp"
"src/RelativeLuminance.cpp"
"src/RedSaturation.h"
"src/RedSaturation.cpp"
"src/CDLuminance.cpp"
"src/Configuration.cpp"
"src/ConfigurationParams.h"
"src/Flash.h"
"src/RelativeLuminance.h"
"src/CDLuminance.h"
"src/FrameRgbConverter.h"
"src/FrameData.h"
"src/FlashDetection.h"
"src/FlashDetection.cpp"
"src/IrisFrame.h"
"src/Log.cpp"
"src/PatternDetection.h"
"src/PatternDetection.cpp"
"src/PhotosensitivityDetector.h"
"src/TransitionTracker.h"
"src/TransitionTrackerByFPS.h"
"src/TransitionTrackerByTime.h"
"src/TransitionTrackerByFPS.cpp"
"src/TransitionTrackerByTime.cpp"
"src/ScopeProfiler.cpp"
)
source_group("Source files" FILES ${SOURCE_FILES})
# Dependencies
find_package(OpenCV CONFIG REQUIRED)
find_package(FFMPEG REQUIRED)
add_subdirectory ("utils")
if(BUILD_SHARED_LIBS)
message("BUILD SHARED LIBRARIES")
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
message("Export symbols")
endif()
endif()
if(BUILD_COVERAGE)
message("BUILD CODE COVERAGE")
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -coverage -fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-coverage -lgcov")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
endif()
# Library definition
add_library(${PROJECT_NAME} ${PUBLIC_HEADERS} ${SOURCE_FILES})
if(BUILD_SHARED_LIBS)
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PUBLIC IRIS_SHARED PRIVATE IRIS_EXPORT)
endif()
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
target_include_directories(${PROJECT_NAME}
PUBLIC
# where the top-level project will look for the library's public headers
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
# where external projects will look for the library's public headers
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_options(${PROJECT_NAME}
PRIVATE $<$<CONFIG:Release>:-Wall>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
PUBLIC_HEADER "${PUBLIC_HEADERS}"
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
utils
${OpenCV_LIBS}
${FFMPEG_LIBRARIES}
)
# ---------------------------------------------------------------------------------------
# Build Example App
# ---------------------------------------------------------------------------------------
if(BUILD_EXAMPLE_APP)
message("Build Iris example app")
add_subdirectory ("example")
endif()
# ---------------------------------------------------------------------------------------
# Build Tests
# ---------------------------------------------------------------------------------------
if(BUILD_TESTS)
message("Build tests")
enable_testing()
add_subdirectory("test/Iris.Tests")
endif()
# ---------------------------------------------------------------------------------------
# Profiler
# ---------------------------------------------------------------------------------------
if(PROFILER)
message("Profiler enabled")
target_compile_definitions(${PROJECT_NAME} PUBLIC -DPROFILING)
endif()
# ---------------------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------------------
if(EXPORT_IRIS)
message("Export Iris")
include(GNUInstallDirs)
set(namespace ${PROJECT_NAME})
# install the target and create export-set
install(TARGETS ${PROJECT_NAME}
EXPORT "${PROJECT_NAME}Targets"
# these variable get default values from GNUInstallDirs
#RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # bin
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # lib
#ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # lib
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # include
)
# generate and install export file
install(EXPORT "${PROJECT_NAME}Targets"
FILE "${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}::
DESTINATION cmake
)
include(CMakePackageConfigHelpers)
# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion
)
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION cmake
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION cmake
)
# generate the export targets for the build tree
export(EXPORT "${PROJECT_NAME}Targets"
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${namespace}::
)
endif()