forked from jcelaya/hdrmerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
356 lines (313 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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
cmake_minimum_required(VERSION 3.4)
cmake_policy(SET CMP0025 NEW)
project(hdrmerge)
if(WIN32)
if(NOT(ALGLIB_ROOT))
message(FATAL_ERROR "When building on Windows, you need to download 'alglib' source and define its root directory in ALGLIB_ROOT !")
else()
message(STATUS "ALGLIB_ROOT = ${ALGLIB_ROOT}")
endif()
endif()
if(APPLE)
if(NOT(ALGLIB_ROOT))
message(FATAL_ERROR "Passage of ALGLIB_ROOT to cmake failed. Download alglib and define its root directory in ALGLIB_ROOT")
else()
message(STATUS "ALGLIB_ROOT = ${ALGLIB_ROOT}")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-unknown-pragmas")
set(PLATFORM "")
# Required and optional packages
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Generate resources automatically
set(CMAKE_AUTORCC ON)
find_package(Qt5 5.6 REQUIRED Core Widgets)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
find_package(LibRaw REQUIRED)
find_package(Exiv2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenMP)
# Commented-out as it doesn't link
#find_package(Boost 1.46 COMPONENTS unit_test_framework)
if(WIN32)
set(ALGLIB_INCLUDES ${ALGLIB_ROOT}/src)
else()
find_package(Alglib REQUIRED)
endif()
include_directories(
"${LibRaw_INCLUDE_DIR}"
"${EXIV2_INCLUDE_DIR}"
"${ZLIB_INCLUDE_DIRS}"
"${ALGLIB_INCLUDES}"
)
if(NOT(CMAKE_BUILD_TYPE))
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if(CMAKE_COMPILER_IS_GNUCC)
set(STRIP -s)
endif()
endif()
# The version number.
set(HDRMERGE_VERSION_MAJOR 0)
set(HDRMERGE_VERSION_MINOR 5)
set(HDRMERGE_VERSION_REV 0)
set(HDRMERGE_VERSION ${HDRMERGE_VERSION_MAJOR}.${HDRMERGE_VERSION_MINOR}.${HDRMERGE_VERSION_REV})
# configure a header file to pass some of the CMake settings to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/src/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
# add the binary tree to the search path for include files so that we will find config.h
include_directories("${PROJECT_BINARY_DIR}")
set(PLATFORM_SOURCES "")
if(WIN32)
# This is required by libraw.h
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32 -DLIBRAW_NODLL")
set(PLATFORM WIN32)
configure_file(
"${PROJECT_SOURCE_DIR}/data/winres.rc"
"${PROJECT_BINARY_DIR}/winres.rc"
)
set(PLATFORM_SOURCES "${PROJECT_BINARY_DIR}/winres.rc")
elseif(APPLE)
set(PLATFORM MACOSX_BUNDLE)
set(MACOSX_BUNDLE_ICON_FILE "icon")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.hdrmerge")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "HDRMerge for macOS v${HDRMERGE_VERSION}")
set(MACOSX_BUNDLE_BUNDLE_NAME "HDRMerge")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${HDRMERGE_VERSION}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${HDRMERGE_VERSION}")
set(MACOSX_BUNDLE_INFO_COPYRIGHT "Copyright 2018 Javier Celaya")
set(PLATFORM_SOURCES "data/images/icon.icns")
endif()
# Sources and headers
set(hdrmerge_sources
src/Image.cpp
src/ImageStack.cpp
src/Bitmap.cpp
src/RawParameters.cpp
src/EditableMask.cpp
src/DngFloatWriter.cpp
src/TiffDirectory.cpp
src/BoxBlur.cpp
src/ExifTransfer.cpp
src/ImageIO.cpp
)
set(hdrmerge_gui_sources
src/AboutDialog.cpp
src/MainWindow.cpp
src/PreviewWidget.cpp
src/DraggableScrollArea.cpp
src/DngPropertiesDialog.cpp
src/LoadOptionsDialog.cpp
src/FileSystem.cpp
)
set(hdrmerge_qobject_headers
src/MainWindow.hpp
src/PreviewWidget.hpp
src/LoadOptionsDialog.hpp
src/DraggableScrollArea.hpp
src/DngPropertiesDialog.hpp
src/AboutDialog.hpp
src/FileSystem.hpp
)
set(hdrmerge_translations
data/hdrmerge_es.ts
)
if(WIN32)
set(alglib_sources
${ALGLIB_ROOT}/src/alglibinternal.cpp
${ALGLIB_ROOT}/src/alglibmisc.cpp
${ALGLIB_ROOT}/src/ap.cpp
${ALGLIB_ROOT}/src/dataanalysis.cpp
${ALGLIB_ROOT}/src/diffequations.cpp
${ALGLIB_ROOT}/src/fasttransforms.cpp
${ALGLIB_ROOT}/src/integration.cpp
${ALGLIB_ROOT}/src/interpolation.cpp
${ALGLIB_ROOT}/src/linalg.cpp
${ALGLIB_ROOT}/src/optimization.cpp
${ALGLIB_ROOT}/src/solvers.cpp
${ALGLIB_ROOT}/src/specialfunctions.cpp
${ALGLIB_ROOT}/src/statistics.cpp
)
endif()
if(APPLE)
set(alglib_sources
${ALGLIB_ROOT}/src/alglibinternal.cpp
${ALGLIB_ROOT}/src/alglibmisc.cpp
${ALGLIB_ROOT}/src/ap.cpp
${ALGLIB_ROOT}/src/dataanalysis.cpp
${ALGLIB_ROOT}/src/diffequations.cpp
${ALGLIB_ROOT}/src/fasttransforms.cpp
${ALGLIB_ROOT}/src/integration.cpp
${ALGLIB_ROOT}/src/interpolation.cpp
${ALGLIB_ROOT}/src/linalg.cpp
${ALGLIB_ROOT}/src/optimization.cpp
${ALGLIB_ROOT}/src/solvers.cpp
${ALGLIB_ROOT}/src/specialfunctions.cpp
${ALGLIB_ROOT}/src/statistics.cpp
)
endif()
# Libs
set(hdrmerge_libs
"${LibRaw_r_LIBRARIES}"
"${EXIV2_LIBRARY}"
"${ZLIB_LIBRARIES}"
)
if(WIN32)
get_filename_component(LIB_PATH "${EXIV2_LIBRARY}" PATH)
find_library(EXPAT_LIBRARY libexpat.a "${LIB_PATH}")
find_library(ICONV_LIBRARY libiconv.a "${LIB_PATH}")
find_library(GETTEXT_LIBRARY libintl.a "${LIB_PATH}")
set(hdrmerge_libs
${hdrmerge_libs}
"${EXPAT_LIBRARY}"
"${GETTEXT_LIBRARY}"
"${ICONV_LIBRARY}"
psapi
wsock32
imm32
winmm
)
remove_definitions(-DQT_DLL)
else()
set(hdrmerge_libs
"${hdrmerge_libs}"
"${ALGLIB_LIBRARIES}"
)
endif()
#QT4_ADD_TRANSLATION(hdrmerge_qm ${hdrmerge_translations})
# Generate the XML version of hdrmerge_qm
foreach(file ${hdrmerge_qm})
get_filename_component(basename ${file} NAME)
set(HDRMERGE_QM_XML "${HDRMERGE_QM_XML}
<file>${basename}</file>")
endforeach()
configure_file(
"${PROJECT_SOURCE_DIR}/data/translations.qrc.in"
"${PROJECT_BINARY_DIR}/translations.qrc"
)
if(WIN32)
add_library(alglib-objects OBJECT ${alglib_sources})
endif()
if(APPLE)
add_library(alglib-objects OBJECT ${alglib_sources})
endif()
if(WIN32)
add_executable(hdrmerge ${PLATFORM}
src/main.cpp
src/Launcher.cpp
data/resources.qrc
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_gui_sources}
${hdrmerge_moc}
$<TARGET_OBJECTS:alglib-objects>
"${PLATFORM_SOURCES}"
)
elseif(APPLE)
add_executable(hdrmerge ${PLATFORM}
src/main.cpp
src/Launcher.cpp
data/resources.qrc
$<TARGET_OBJECTS:alglib-objects>
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_gui_sources}
${hdrmerge_moc}
"${PLATFORM_SOURCES}"
)
else()
add_executable(hdrmerge ${PLATFORM}
src/main.cpp
src/Launcher.cpp
data/resources.qrc
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_gui_sources}
${hdrmerge_moc}
"${PLATFORM_SOURCES}"
)
endif()
target_link_libraries(hdrmerge ${STRIP} ${hdrmerge_libs} Qt5::Widgets)
if(WIN32)
# Compile a target without GUI, for the .com executable
add_executable(hdrmerge-nogui
src/main.cpp
src/Launcher.cpp
data/resources.qrc
${hdrmerge_translations}
${hdrmerge_sources}
${hdrmerge_moc}
$<TARGET_OBJECTS:alglib-objects>
"${PLATFORM_SOURCES}"
)
# WARNING: ImageIO class need QImage which need Qt5::Widgets
# Launcher.cpp need QApplication which need Qt5::Widgets
target_link_libraries(hdrmerge-nogui ${STRIP} ${hdrmerge_libs} Qt5::Widgets Qt5::Core)
set_target_properties(hdrmerge-nogui PROPERTIES COMPILE_DEFINITIONS "NO_GUI")
# Create the installer with makensis
find_program(MAKENSIS_EXECUTABLE makensis.exe PATH_SUFFIXES "NSIS/Bin")
if(MAKENSIS_EXECUTABLE)
message(STATUS "NSIS found")
set(SETUP_PROG hdrmerge-setup${WIN_ARCH}-${HDRMERGE_VERSION}.exe)
string(REPLACE "/" "\\" PROJ_SRC_DIR "${PROJECT_SOURCE_DIR}")
message(STATUS "PROJ_SRC_DIR = ${PROJ_SRC_DIR}")
# ASSUMING YOU'RE USING EXIV2 BUNDLED WITH MSYS2
find_program(MINGW_LIB_DIR exiv2.exe)
if(MINGW_LIB_DIR)
get_filename_component(MINGW_LIB_DIR "${MINGW_LIB_DIR}" PATH)
string(REPLACE "/" "\\" MINGW_LIB_DIR "${MINGW_LIB_DIR}")
message(STATUS "MINGW_LIB_DIR = ${MINGW_LIB_DIR}")
set(QT5_PLUGINS_DIR "${MINGW_LIB_DIR}\\..\\share\\qt5\\plugins")
message(STATUS "QT5_PLUGINS_DIR = ${QT5_PLUGINS_DIR}")
configure_file(
"${PROJECT_SOURCE_DIR}/data/setup.nsi"
"${PROJECT_BINARY_DIR}/setup.nsi" @ONLY
)
add_custom_command(OUTPUT ${SETUP_PROG}
COMMAND "${MAKENSIS_EXECUTABLE}" -V2 setup.nsi
MAIN_DEPENDENCY setup.nsi
DEPENDS "${PROJECT_BINARY_DIR}/hdrmerge.exe"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
add_custom_target(hdrmerge-setup ALL DEPENDS "${PROJECT_BINARY_DIR}/${SETUP_PROG}")
else(MINGW_LIB_DIR)
message(STATUS "Unable to locate the 'bin' directory to get the dependencies")
endif(MINGW_LIB_DIR)
else()
message(STATUS "NSIS not found")
endif()
elseif(APPLE)
set_source_files_properties(data/images/icon.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
install(TARGETS hdrmerge BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "bin")
endif()
message(STATUS "Install binary to: " ${CMAKE_INSTALL_BINDIR})
install(TARGETS hdrmerge DESTINATION ${CMAKE_INSTALL_BINDIR})
find_program(XDG-DESKTOP-MENU_EXECUTABLE xdg-desktop-menu)
find_program(XDG-ICON-RESOURCE_EXECUTABLE xdg-icon-resource)
if(XDG-DESKTOP-MENU_EXECUTABLE AND XDG-ICON-RESOURCE_EXECUTABLE)
configure_file(
"${PROJECT_SOURCE_DIR}/data/hdrmerge.desktop"
"${PROJECT_BINARY_DIR}/hdrmerge.desktop"
)
install(CODE "
execute_process(COMMAND \"${XDG-ICON-RESOURCE_EXECUTABLE}\" install --novendor --size 128 \"${PROJECT_SOURCE_DIR}/data/images/icon.png\" hdrmerge-icon)
execute_process(COMMAND \"${XDG-DESKTOP-MENU_EXECUTABLE}\" install --novendor \"${PROJECT_BINARY_DIR}/hdrmerge.desktop\")"
)
endif()
endif()
if(Boost_FOUND)
add_subdirectory(test)
endif()