forked from afichet/openexr-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
335 lines (275 loc) · 9.75 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
334
335
cmake_minimum_required(VERSION 3.5)
project(openexr-viewer
VERSION 0.6.0
DESCRIPTION "Simple Viewer for OpenEXR files with detailed metadata display"
HOMEPAGE_URL "https://github.com/afichet/openexr-viewer"
LANGUAGES CXX
)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
cmake_policy(SET CMP0074 NEW)
include(GNUInstallDirs)
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(MACOSX_BUNDLE_BUNDLE_NAME "OpenEXR-Viewer")
set(MACOSX_BUNDLE_CONTENTS "${CMAKE_CURRENT_BINARY_DIR}/${MACOSX_BUNDLE_BUNDLE_NAME}.app/Contents")
set(MACOSX_BUNDLE_RESOUCES "${MACOSX_BUNDLE_CONTENTS}/Resources")
set(MACOSX_BUNDLE_ICON_FILE "openexr-viewer.icns")
set(MACOSX_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/deploy/icon/${MACOSX_BUNDLE_ICON_FILE}")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${MACOSX_BUNDLE_RESOUCES}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MACOSX_BUNDLE_ICON}" "${MACOSX_BUNDLE_RESOUCES}")
endif (APPLE)
# ----------------------------------------------------------------------------
# Dependencies
# ----------------------------------------------------------------------------
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
find_package(OpenMP)
# Those are provided by Imath and OpenEXR 3.0
find_package(Imath REQUIRED)
find_package(OpenEXR REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
# ----------------------------------------------------------------------------
# Source
# ----------------------------------------------------------------------------
message(${CMAKE_PROJECT_VERSION})
configure_file(src/config.h.in config.h)
set(PROJECT_SOURCES
src/main.cpp
src/view/mainwindow.cpp
src/view/mainwindow.h
src/view/mainwindow.ui
src/view/about.cpp
src/view/about.h
src/view/about.ui
src/view/ImageFileWidget.cpp
src/view/ImageFileWidget.h
src/view/GraphicsScene.cpp
src/view/GraphicsScene.h
src/view/GraphicsView.cpp
src/view/GraphicsView.h
src/view/RGBFramebufferWidget.cpp
src/view/RGBFramebufferWidget.h
src/view/RGBFramebufferWidget.ui
src/view/YFramebufferWidget.cpp
src/view/YFramebufferWidget.h
src/view/YFramebufferWidget.ui
src/view/ScaleWidget.cpp
src/view/ScaleWidget.h
# ------------------------------------------------------------------------
# Model
# ------------------------------------------------------------------------
src/model/OpenEXRImage.cpp
src/model/OpenEXRImage.h
# OpenEXR attributes
src/model/attribute/HeaderItem.cpp
src/model/attribute/HeaderItem.h
src/model/attribute/HeaderModel.cpp
src/model/attribute/HeaderModel.h
# OpenEXR layer fields (specific kind of attributes)
src/model/attribute/LayerItem.cpp
src/model/attribute/LayerItem.h
src/model/attribute/LayerModel.cpp
src/model/attribute/LayerModel.h
# Framebuffers (image content i.e. layer data)
src/model/framebuffer/FramebufferModel.cpp
src/model/framebuffer/FramebufferModel.h
src/model/framebuffer/YFramebufferModel.cpp
src/model/framebuffer/YFramebufferModel.h
src/model/framebuffer/RGBFramebufferModel.cpp
src/model/framebuffer/RGBFramebufferModel.h
# Stream
src/model/StdIStream.cpp
src/model/StdIStream.h
# ------------------------------------------------------------------------
# Utilities
# ------------------------------------------------------------------------
src/util/Colormap.cpp
src/util/Colormap.h
src/util/TabulatedColormap.cpp
src/util/TabulatedColormap.h
src/util/BBGRColormap.cpp
src/util/BBGRColormap.h
src/util/YColormap.cpp
src/util/YColormap.h
src/util/ColormapModule.h
src/util/ColormapModule.cpp
src/util/ColorTransform.h
src/util/ColorTransform.cpp
openexr-viewer.rc
assets/themes/dark_flat.qrc
assets/icons/icons.qrc
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
if (WIN32)
qt_add_executable(openexr-viewer WIN32
${PROJECT_SOURCES}
)
elseif(APPLE)
qt_add_executable(openexr-viewer MACOSX_BUNDLE
${PROJECT_SOURCES}
)
else()
qt_add_executable(openexr-viewer
${PROJECT_SOURCES}
)
endif()
else()
if(WIN32)
add_executable(openexr-viewer WIN32
${PROJECT_SOURCES}
)
elseif(APPLE)
add_executable(openexr-viewer MACOSX_BUNDLE
${PROJECT_SOURCES}
)
else()
add_executable(openexr-viewer
${PROJECT_SOURCES}
)
endif()
endif()
if (APPLE)
set_target_properties(openexr-viewer PROPERTIES
OUTPUT_NAME ${MACOSX_BUNDLE_BUNDLE_NAME}
MACOSX_BUNDLE TRUE
MACOSX_RPATH TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.gitlab.afichet.openexrviewer
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
RESOURCE "${RESOURCE_FILES}"
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
XCODE_ATTRIBUTE_EXECUTABLE_NAME "exeName"
)
endif ()
target_include_directories(openexr-viewer PRIVATE src)
target_include_directories(openexr-viewer PRIVATE 3rdparty/data)
target_include_directories(openexr-viewer PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
target_link_libraries(openexr-viewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(openexr-viewer PRIVATE Imath::Imath OpenEXR::OpenEXR)
if((OpenMP_CXX_FOUND) OR (OpenMP_FOUND))
target_link_libraries(openexr-viewer PRIVATE OpenMP::OpenMP_CXX)
# target_link_libraries(openexr-viewer PRIVATE OpenMP::OpenMP_C)
endif()
if (WIN32)
add_custom_command(
TARGET openexr-viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::Widgets>
$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::Core>
$<TARGET_FILE:Qt${QT_VERSION_MAJOR}::Gui>
$<TARGET_FILE_DIR:openexr-viewer>
)
endif (WIN32)
# Warnings
if(MSVC)
target_compile_options(openexr-viewer PUBLIC /W4)
else()
target_compile_options(openexr-viewer PUBLIC -Wall -Wextra -Wpedantic)
endif()
# ----------------------------------------------------------------------------
# Install Rules
# ----------------------------------------------------------------------------
if (UNIX AND NOT APPLE)
install(TARGETS openexr-viewer)
# Application desktop entry
install(
FILES
deploy/linux/openexr-viewer.desktop
DESTINATION
share/applications
)
# MIME data
install(
FILES
deploy/linux/openexr-viewer.xml
DESTINATION
share/mime/packages
)
# Application icon
install(
FILES
deploy/icon/openexr-viewer.png
DESTINATION
share/pixmaps
)
# Metadata
install(
FILES
deploy/linux/openexr-viewer.metainfo.xml
DESTINATION
share/metainfo
)
elseif (APPLE)
install(TARGETS openexr-viewer DESTINATION "." COMPONENT Libraries)
include(Macdeployqt)
macdeployqt(openexr-viewer)
elseif (WIN32)
install(
TARGETS
openexr-viewer
DESTINATION
${CMAKE_INSTALL_BINDIR}
)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
install(
FILES
"${ZLIB_ROOT}/bin/zlib.dll" # Zlib
$<TARGET_FILE:Imath::Imath> # OpenEXR
$<TARGET_FILE:OpenEXR::Iex>
$<TARGET_FILE:OpenEXR::IlmThread>
$<TARGET_FILE:OpenEXR::OpenEXR>
${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} # Windows DLLs
DESTINATION
${CMAKE_INSTALL_BINDIR}
)
include(Windeployqt)
windeployqt(openexr-viewer ${CMAKE_INSTALL_BINDIR})
endif ()
# ----------------------------------------------------------------------------
# Packaging
# ----------------------------------------------------------------------------
# set(CPACK_PACKAGE_NAME "OpenEXR Viewer")
# set(CPACK_PACKAGE_VENDOR "")
set(CPACK_PACKAGE_DESCRIPTION "Simple Viewer for OpenEXR files with detailed metadata display")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenEXR Viewer")
# set(CPACK_PACKAGE_ICON "")
# set(CPACK_PACKAGE_CHECKSUM "SHA512")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/LICENSE")
# set(CPACK_RESOURCE_FILE_README "README.md")
set(CPACK_MONOLITHIC_INSTALL True)
set(CPACK_PACKAGE_EXECUTABLES "openexr-viewer;OpenEXR Viewer")
# NSIS specific settings
if(CPACK_GENERATOR MATCHES "NSIS")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_LIST_DIR}/deploy/icon/openexr-viewer.ico")
set(CPACK_NSIS_HELP_LINK "")
set(CPACK_NSIS_URL_INFO_ABOUT "")
set(CPACK_CREATE_DESKTOP_LINKS "OpenEXR Viewer")
set(CPACK_NSIS_INSTALLED_ICON_NAME "openexr-viewer.exe")
set(CPACK_NSIS_MENU_LINKS "openexr-viewer.exe" "OpenEXR Viewer")
set(CPACK_NSIS_MODIFY_PATH OFF)
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "openexr-viewer.exe")
set(CPACK_PACKAGE_VENDOR "Lambda")
endif(CPACK_GENERATOR MATCHES "NSIS")
if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
endif("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
if (APPLE)
set(CPACK_BUNDLE_NAME "${MACOSX_BUNDLE_BUNDLE_NAME}")
set(CPACK_BUNDLE_PLIST "${MACOSX_BUNDLE_CONTENTS}/Info.plist")
set(CPACK_PACKAGE_ICON "${MACOSX_BUNDLE_ICON}")
set(CPACK_BUNDLE_ICON "${MACOSX_BUNDLE_ICON}")
endif (APPLE)
# CPack
include(CPack)