-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
272 lines (243 loc) · 8.39 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
cmake_minimum_required(VERSION 3.19)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0114 NEW)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
set(TLRENDER_VERSION_MAJOR "0")
set(TLRENDER_VERSION_MINOR "1")
set(TLRENDER_VERSION_PATCH "0")
set(TLRENDER_VERSION ${TLRENDER_VERSION_MAJOR}.${TLRENDER_VERSION_MINOR}.${TLRENDER_VERSION_PATCH})
add_definitions(-DTLRENDER_VERSION_MAJOR=${TLRENDER_VERSION_MAJOR})
add_definitions(-DTLRENDER_VERSION_MINOR=${TLRENDER_VERSION_MINOR})
add_definitions(-DTLRENDER_VERSION_PATCH=${TLRENDER_VERSION_PATCH})
add_definitions(-DTLRENDER_VERSION="${TLRENDER_VERSION}")
project(
tlRender
VERSION ${TLRENDER_VERSION}
DESCRIPTION "tlRender is an open source library for building playback and review applications for visual effects, film, and animation"
HOMEPAGE_URL "https://github.com/darbyjohnston/tlRender"
LANGUAGES CXX C)
#-------------------------------------------------------------------------------
# Build options
set(TLRENDER_PYTHON FALSE CACHE BOOL "Enable Python support (for OTIO Python adapters)")
set(TLRENDER_API "GL_4_1" CACHE STRING "Graphics API (GL_4_1, GL_4_1_Debug, GLES_2)")
set(TLRENDER_GLFW TRUE CACHE BOOL "Enable support for GLFW")
set(TLRENDER_NET FALSE CACHE BOOL "Enable network support")
set(TLRENDER_OCIO TRUE CACHE BOOL "Enable support for OpenColorIO")
set(TLRENDER_SDL2 TRUE CACHE BOOL "Enable support for SDL2")
set(TLRENDER_SDL3 FALSE CACHE BOOL "Enable support for SDL3")
set(TLRENDER_JPEG TRUE CACHE BOOL "Enable support for JPEG I/O")
set(TLRENDER_TIFF TRUE CACHE BOOL "Enable support for TIFF I/O")
set(TLRENDER_STB TRUE CACHE BOOL "Enable support for STB I/O (TGA, BMP, PSD)")
set(TLRENDER_PNG TRUE CACHE BOOL "Enable support for PNG I/O")
set(TLRENDER_EXR TRUE CACHE BOOL "Enable support for EXR I/O")
set(TLRENDER_FFMPEG TRUE CACHE BOOL "Enable support for FFmpeg I/O")
set(TLRENDER_USD FALSE CACHE BOOL "Enable support for USD")
set(TLRENDER_BMD FALSE CACHE BOOL "Enable support for Blackmagic Design devices")
set(TLRENDER_BMD_SDK "" CACHE PATH "Full path to the Blackmagic Design SDK")
if(WIN32 OR APPLE)
set(TLRENDER_NFD_DEFAULT TRUE)
else()
set(TLRENDER_NFD_DEFAULT FALSE)
endif()
set(TLRENDER_NFD ${TLRENDER_NFD_DEFAULT} CACHE BOOL "Enable support for native file dialogs")
set(TLRENDER_QT6 FALSE CACHE BOOL "Enable support for Qt6")
set(TLRENDER_QT5 FALSE CACHE BOOL "Enable support for Qt5")
set(TLRENDER_PROGRAMS TRUE CACHE BOOL "Build programs")
set(TLRENDER_EXAMPLES TRUE CACHE BOOL "Build examples")
set(TLRENDER_TESTS TRUE CACHE BOOL "Build tests")
if(APPLE)
set(TLRENDER_IGNORE_PREFIX_PATH_DEFAULT /opt/homebrew)
endif()
set(TLRENDER_IGNORE_PREFIX_PATH ${TLRENDER_IGNORE_PREFIX_PATH_DEFAULT} CACHE STRING "Ignore the given prefix path")
set(TLRENDER_GCOV FALSE CACHE BOOL "Enable gcov code coverage")
set(TLRENDER_GPROF FALSE CACHE BOOL "Enable gprof code profiling")
#-------------------------------------------------------------------------------
# Internal configuration
list(PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
if(TLRENDER_PYTHON)
add_definitions(-DTLRENDER_PYTHON)
endif()
if(TLRENDER_USD)
add_definitions(-DTLRENDER_USD)
endif()
if(TLRENDER_BMD)
add_definitions(-DTLRENDER_BMD)
endif()
if(TLRENDER_QT6 AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
add_definitions(-DTLRENDER_QT6)
elseif(TLRENDER_QT5 AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
add_definitions(-DTLRENDER_QT5)
endif()
if(TLRENDER_IGNORE_PREFIX_PATH)
set(CMAKE_IGNORE_PREFIX_PATH ${TLRENDER_IGNORE_PREFIX_PATH})
endif()
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
add_definitions(-DTLRENDER_ASSERT)
endif()
if(TLRENDER_TESTS)
add_definitions(-DTLRENDER_SAMPLE_DATA="${CMAKE_CURRENT_SOURCE_DIR}/etc/SampleData")
set(CTEST_OUTPUT_ON_FAILURE ON)
enable_testing()
endif()
include_directories(
${PROJECT_SOURCE_DIR}/deps
${PROJECT_SOURCE_DIR}/lib
${PROJECT_SOURCE_DIR}/etc
${PROJECT_SOURCE_DIR}/tests)
if ("${TLRENDER_API}" STREQUAL "GL_4_1")
include_directories(${PROJECT_SOURCE_DIR}/deps/glad_GL_4_1/include)
elseif ("${TLRENDER_API}" STREQUAL "GL_4_1_Debug")
include_directories(${PROJECT_SOURCE_DIR}/deps/glad_GL_4_1_Debug/include)
elseif ("${TLRENDER_API}" STREQUAL "GLES_2")
include_directories(${PROJECT_SOURCE_DIR}/deps/glad_GLES_2/include)
endif()
if(TLRENDER_GPROF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
endif()
if(TLRENDER_GCOV)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")# -fkeep-inline-functions")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")# -fkeep-inline-functions")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
if(APPLE)
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
endif()
if(WIN32)
elseif(APPLE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
else()
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "../lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#-------------------------------------------------------------------------------
# Dependencies
# Required dependencies
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Imath REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(ZLIB REQUIRED)
find_package(minizip REQUIRED)
find_package(OTIO REQUIRED)
find_package(Freetype REQUIRED)
# GLFW dependency
if(TLRENDER_GLFW)
find_package(glfw3 REQUIRED)
add_definitions(-DTLRENDER_GLFW)
endif()
# OpenColorIO dependencies
if(TLRENDER_OCIO AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
find_package(OpenColorIO REQUIRED)
add_definitions(-DTLRENDER_OCIO)
endif()
# SDL dependencies
if(TLRENDER_SDL2)
find_package(SDL2 REQUIRED)
add_definitions(-DTLRENDER_SDL2)
endif()
if(TLRENDER_SDL3)
find_package(SDL3 REQUIRED)
add_definitions(-DTLRENDER_SDL3)
endif()
# I/O dependencies
if(TLRENDER_JPEG)
find_package(libjpeg-turbo)
if(libjpeg-turbo_FOUND)
add_definitions(-DTLRENDER_JPEG)
endif()
endif()
if(TLRENDER_TIFF)
find_package(TIFF)
if(TIFF_FOUND)
add_definitions(-DTLRENDER_TIFF)
endif()
endif()
if(TLRENDER_STB)
add_definitions(-DTLRENDER_STB)
endif()
if(TLRENDER_PNG)
find_package(PNG)
if(PNG_FOUND)
add_definitions(-DTLRENDER_PNG)
endif()
endif()
if(TLRENDER_EXR)
find_package(OpenEXR)
if(OpenEXR_FOUND)
add_definitions(-DTLRENDER_EXR)
endif()
endif()
if(TLRENDER_FFMPEG)
find_package(FFmpeg)
if(FFmpeg_FOUND)
add_definitions(-DTLRENDER_FFMPEG)
endif()
endif()
if(TLRENDER_USD)
find_package(pxr)
if(pxr_FOUND)
add_definitions(-DTLRENDER_USD)
endif()
endif()
# Python dependencies
if(TLRENDER_PYTHON)
find_package(Python3 REQUIRED COMPONENTS Development)
endif()
# Native file dialog dependencies
if(TLRENDER_NFD)
find_package(NFD)
if(NFD_FOUND)
add_definitions(-DTLRENDER_NFD)
endif()
endif()
# Qt dependencies
if(TLRENDER_QT6 AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 REQUIRED COMPONENTS Quick Widgets OpenGLWidgets Svg HINTS "$ENV{QTDIR}")
elseif(TLRENDER_QT5 AND NOT "${TLRENDER_API}" STREQUAL "GLES_2")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt5 REQUIRED COMPONENTS Quick Widgets Svg HINTS "$ENV{QTDIR}")
endif()
#-------------------------------------------------------------------------------
# Sub-directories
add_definitions(-DTLRENDER_API_${TLRENDER_API})
if("${TLRENDER_API}" STREQUAL "GL_4_1_Debug")
add_definitions(-DTLRENDER_API_GL_4_1)
endif()
add_subdirectory(deps/glad_${TLRENDER_API})
add_subdirectory(lib)
if(TLRENDER_PROGRAMS)
add_subdirectory(bin)
endif()
if(TLRENDER_TESTS)
add_subdirectory(tests)
endif()
if(TLRENDER_EXAMPLES)
add_subdirectory(examples)
endif()
add_subdirectory(etc)
#-------------------------------------------------------------------------------
# Packaging
if(CMAKE_BUILD_TYPE MATCHES "^Release$")
include(Package)
include(CPack)
include(InstallRequiredSystemLibraries)
endif()