-
Notifications
You must be signed in to change notification settings - Fork 59
/
CMakeLists.txt
333 lines (295 loc) · 10.6 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
cmake_minimum_required(VERSION 3.18)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0091 NEW)
set(DJV_VERSION_MAJOR "2")
set(DJV_VERSION_MINOR "0")
set(DJV_VERSION_PATCH "9")
set(DJV_VERSION ${DJV_VERSION_MAJOR}.${DJV_VERSION_MINOR}.${DJV_VERSION_PATCH})
add_definitions(-DDJV_VERSION_MAJOR=${DJV_VERSION_MAJOR})
add_definitions(-DDJV_VERSION_MINOR=${DJV_VERSION_MINOR})
add_definitions(-DDJV_VERSION_PATCH=${DJV_VERSION_PATCH})
add_definitions(-DDJV_VERSION="${DJV_VERSION}")
project(
DJV
VERSION ${DJV_VERSION}
DESCRIPTION "Professional review software for VFX, animation, and film production"
HOMEPAGE_URL "https://github.com/darbyjohnston/DJV"
LANGUAGES C CXX)
list(PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
#-------------------------------------------------------------------------------
# Options
#-------------------------------------------------------------------------------
# General options.
set(DJV_BUILD_TINY FALSE CACHE BOOL "Enable a 'tiny' build (libraries + tests)")
if(DJV_BUILD_TINY)
add_definitions(-DDJV_BUILD_TINY)
endif()
set(DJV_BUILD_MINIMAL FALSE CACHE BOOL "Enable a minimal build (libraries + tests + examples)")
if(DJV_BUILD_MINIMAL)
add_definitions(-DDJV_BUILD_MINIMAL)
endif()
set(DJV_BUILD_EXPERIMENTS FALSE CACHE BOOL "Build experiments")
set(DJV_THIRD_PARTY_OPTIONAL TRUE CACHE BOOL "Use optional third party dependencies")
# Test options.
enable_testing()
set(DJV_GPROF FALSE CACHE BOOL "Enable gprof profiling")
set(DJV_GCOV FALSE CACHE BOOL "Enable gcov code coverage")
# Experimental options.
set(DJV_GL_ES2 FALSE CACHE BOOL "OpenGL ES 2.0 rendering (experiemental)")
if(DJV_GL_ES2)
add_definitions(-DDJV_GL_ES2)
endif()
set(DJV_PYTHON FALSE CACHE BOOL "Python support (experimental)")
if(DJV_PYTHON)
add_definitions(-DDJV_PYTHON)
endif()
# Debugging options.
set(DJV_SYSTEM_DOT_GRAPH FALSE CACHE BOOL "Write a Graphviz .dot file (systems.dot) of the system dependencies")
#-------------------------------------------------------------------------------
# Configuration
#-------------------------------------------------------------------------------
# Setup the platform we are building for.
if(APPLE)
set(DJV_PLATFORM_MACOS TRUE)
add_definitions(-DDJV_PLATFORM_MACOS)
elseif(UNIX)
string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} Linux _TMP)
if(_TMP)
set(DJV_PLATFORM_LINUX TRUE)
add_definitions(-DDJV_PLATFORM_LINUX)
set(CMAKE_C_FLAGS -fPIC)
set(CMAKE_CXX_FLAGS -fPIC)
endif()
elseif(WIN32)
set(DJV_PLATFORM_WINDOWS TRUE)
add_definitions(-DDJV_PLATFORM_WINDOWS)
set(CMAKE_C_FLAGS "/MP /EHsc")
set(CMAKE_CXX_FLAGS "/MP /EHsc")
endif()
# Set the output directories for the build.
set(DJV_BUILD_DIR ${PROJECT_BINARY_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${DJV_BUILD_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${DJV_BUILD_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${DJV_BUILD_DIR}/bin)
# Set the installation directories.
set(DJV_INSTALL_BIN bin)
set(DJV_INSTALL_LIB lib)
set(DJV_INSTALL_DOCS docs)
# set the include directories.
set(INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/bin
${CMAKE_SOURCE_DIR}/tests)
if(DJV_PYTHON)
set(INCLUDE_DIRS
${INCLUDE_DIRS}
${pybind11_SOURCE_DIR}/include)
endif()
include_directories(${INCLUDE_DIRS})
# Miscellaneous settings.
#add_definitions(-DDJV_MMAP)
#add_definitions(-DDJV_GL_PBO)
add_definitions(-DDJV_ASSERT)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(DJV_DEMO)
add_definitions(-DDJV_DEMO)
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
endif()
# Test settings.
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCXX)
if(DJV_GPROF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
endif()
if(DJV_GCOV)
include(CodeCoverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_COVERAGE}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_COVERAGE}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_COVERAGE}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_COVERAGE}")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_STATIC_LINKER_FLAGS_COVERAGE}")
endif()
endif()
endif()
# Compiler settings.
if(APPLE)
set(CMAKE_CXX_STANDARD 11)
endif()
#-------------------------------------------------------------------------------
# Third Party Dependencies
#-------------------------------------------------------------------------------
# Add threads and OpenGL dependencies.
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
# Add Python dependency.
if(DJV_PYTHON)
find_package(Python)
endif()
# Set the list of required third party dependencies.
set(DJV_THIRD_PARTY_REQUIRED_DEPS
glad
FSeq
ZLIB
GLM
GLFW
RapidJSON
#OpenAL
RtAudio
IlmBase
PNG
OCIO
#OTIO
FreeType)
# Set the list of optional third party dependencies.
if(WIN32)
else()
set(DJV_THIRD_PARTY_OPTIONAL_DEPS
${DJV_THIRD_PARTY_OPTIONAL_DEPS}
#MbedTLS
)
endif()
set(DJV_THIRD_PARTY_OPTIONAL_DEPS
${DJV_THIRD_PARTY_OPTIONAL_DEPS}
#curl
FFmpeg
JPEG
TIFF
OpenEXR
#OpenCV
)
if(WIN32)
set(DJV_THIRD_PARTY_OPTIONAL_DEPS
${DJV_THIRD_PARTY_OPTIONAL_DEPS}
OpenNURBS)
else()
endif()
# Set whether shared libraries are used for the dependencies.
set(glad_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(FSeq_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(ZLIB_SHARED_LIBS ${BUILD_SHARED_LIBS})
#set(OPENAL_SHARED_LIBS ON)
set(RtAudio_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(JPEG_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(TIFF_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(PNG_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(ILMBASE_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(OPENEXR_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(OCIO_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(OTIO_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(FFmpeg_SHARED_LIBS ON)
# Add the third party dependencies.
foreach(PACKAGE ${DJV_THIRD_PARTY_REQUIRED_DEPS})
find_package(${PACKAGE} REQUIRED)
endforeach()
if(DJV_THIRD_PARTY_OPTIONAL)
foreach(PACKAGE ${DJV_THIRD_PARTY_OPTIONAL_DEPS})
find_package(${PACKAGE})
endforeach()
endif()
#-------------------------------------------------------------------------------
# Resources
#-------------------------------------------------------------------------------
# Text files (translations).
file(GLOB DJV_TEXT_FILES ${CMAKE_SOURCE_DIR}/etc/Text/*.text)
file(COPY ${DJV_TEXT_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Text)
install(FILES ${DJV_TEXT_FILES} DESTINATION etc/Text)
# Fonts.
file(GLOB_RECURSE DJV_FONT_FILES ${CMAKE_SOURCE_DIR}/etc/Fonts/*.ttf ${CMAKE_SOURCE_DIR}/etc/Fonts/*.otf)
file(COPY ${DJV_FONT_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Fonts)
install(FILES ${DJV_FONT_FILES} DESTINATION etc/Fonts)
# Icons.
file(GLOB DJV_ICON_FILES
${CMAKE_SOURCE_DIR}/etc/Icons/*.ppm
${CMAKE_SOURCE_DIR}/etc/Icons/*.png)
file(COPY ${DJV_ICON_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Icons)
install(FILES ${DJV_ICON_FILES} DESTINATION etc/Icons)
foreach(DPI 32 48 64 96 120 144 168 192 216 240 264 288)
file(GLOB_RECURSE DJV_ICON_FILES
${CMAKE_SOURCE_DIR}/etc/Icons/${DPI}DPI/*.ppm
${CMAKE_SOURCE_DIR}/etc/Icons/${DPI}DPI/*.png)
file(COPY ${DJV_ICON_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Icons/${DPI}DPI)
install(FILES ${DJV_ICON_FILES} DESTINATION etc/Icons/${DPI}DPI)
endforeach()
# Images.
file(GLOB_RECURSE DJV_IMAGE_FILES
${CMAKE_SOURCE_DIR}/etc/Images/*.ppm
${CMAKE_SOURCE_DIR}/etc/Images/*.png)
file(COPY ${DJV_IMAGE_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Images)
install(FILES ${DJV_IMAGE_FILES} DESTINATION etc/Images)
# Models.
file(GLOB_RECURSE DJV_MODEL_FILES
${CMAKE_SOURCE_DIR}/etc/Models/*.obj
${CMAKE_SOURCE_DIR}/etc/Models/*.3dm)
file(COPY ${DJV_MODEL_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Models)
install(FILES ${DJV_MODEL_FILES} DESTINATION etc/Models)
# Audio.
file(GLOB_RECURSE DJV_AUDIO_FILES ${CMAKE_SOURCE_DIR}/etc/Audio/*.wav)
file(COPY ${DJV_AUDIO_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Audio)
install(FILES ${DJV_AUDIO_FILES} DESTINATION etc/Audio)
# Shaders.
if(DJV_GL_ES2)
file(GLOB_RECURSE DJV_SHADER_FILES ${CMAKE_SOURCE_DIR}/etc/Shaders/GL2ES/*.glsl)
else()
file(GLOB_RECURSE DJV_SHADER_FILES ${CMAKE_SOURCE_DIR}/etc/Shaders/GL4_1/*.glsl)
endif()
file(COPY ${DJV_SHADER_FILES} DESTINATION ${DJV_BUILD_DIR}/etc/Shaders)
install(FILES ${DJV_SHADER_FILES} DESTINATION etc/Shaders)
# Color.
file(GLOB DJV_COLOR_DIRS ${CMAKE_SOURCE_DIR}/etc/Color/*)
foreach(DIR ${DJV_COLOR_DIRS})
file(COPY ${DIR} DESTINATION ${DJV_BUILD_DIR}/etc/Color)
install(DIRECTORY ${DIR} DESTINATION etc/Color)
endforeach()
#function(add_vulkan_vert_shader TARGET ARG)
# add_custom_command(
# OUTPUT ${DJV_SHADERS_DIR}/${ARG}.spv
# COMMAND ${CMAKE_COMMAND} -E make_directory ${DJV_SHADERS_DIR}
# COMMAND ${Vulkan_SHADER_COMPILER} -V ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}.vert -o ${DJV_SHADERS_DIR}/${ARG}.spv
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}.vert)
# add_custom_target(${ARG} DEPENDS ${DJV_SHADERS_DIR}/${ARG}.spv)
# set_target_properties(${ARG} PROPERTIES FOLDER "Shaders")
# add_dependencies(${TARGET} ${ARG})
# install(FILES ${DJV_SHADERS_DIR}/${ARG}.spv DESTINATION etc/Shaders)
#endfunction()
#
#function(add_vulkan_frag_shader TARGET ARG)
# add_custom_command(
# OUTPUT ${DJV_SHADERS_DIR}/${ARG}.spv
# COMMAND ${CMAKE_COMMAND} -E make_directory ${DJV_SHADERS_DIR}
# COMMAND ${Vulkan_SHADER_COMPILER} -V ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}.frag -o ${DJV_SHADERS_DIR}/${ARG}.spv
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ARG}.frag)
# add_custom_target(${ARG} DEPENDS ${DJV_SHADERS_DIR}/${ARG}.spv)
# set_target_properties(${ARG} PROPERTIES FOLDER "Shaders")
# add_dependencies(${TARGET} ${ARG})
# install(FILES ${DJV_SHADERS_DIR}/${ARG}.spv DESTINATION etc/Shaders)
#endfunction()
set(DJV_RESOURCE_FILES
${DJV_TEXT_FILES}
${DJV_FONT_FILES}
${DJV_ICON_FILES}
${DJV_IMAGE_FILES}
${DJV_MODEL_FILES}
${DJV_AUDIO_FILES}
${DJV_SHADER_FILES}
${DJV_COLOR_DIRS})
#-------------------------------------------------------------------------------
# Subdirectories
#-------------------------------------------------------------------------------
include(djvPackage)
add_subdirectory(lib)
add_subdirectory(tests)
if(DJV_BUILD_TINY)
elseif(DJV_BUILD_MINIMAL)
add_subdirectory(examples)
else()
add_subdirectory(bin)
add_subdirectory(docs)
add_subdirectory(examples)
endif()
if(DJV_BUILD_EXPERIMENTS)
add_subdirectory(experiments)
endif()
include(CPack)