-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt.in
301 lines (258 loc) · 12 KB
/
CMakeLists.txt.in
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
################################################################################
##
## Photivo
##
## Copyright (C) 2013 Sergey Salnikov <[email protected]>
##
## This file is part of Photivo.
##
## Photivo is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 3
## as published by the Free Software Foundation.
##
## Photivo is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Photivo. If not, see <http://www.gnu.org/licenses/>.
##
################################################################################
#
# The file CMakeLists.txt is generated automatically and you shouldn't
# edit it directly. Instead of this you should edit CMakeLists.txt.in
# and then run a script CMakeGenerate.py.
# The script extracts all sources, headers and UIs from the
# photivoProject/photivoProject.pro file and includes them into
# CMakeLists.txt. So these variables should be lived empty in CMakeLists.txt.in.
#
################################################################################
#
# Besides compiling Photivo you can create an archive containing all sources
# without hg metadata by calling "make package_source". You are supposed to give this
# command in a subdirectory called build* or BUILD*. You can also create a
# binary archive by calling "make package".
#
################################################################################
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
PROJECT( photivo )
if( NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6 )
message( WARNING "\nAt least GCC 4.6 is required to build Photivo." )
endif( NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.6 )
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
endif( NOT CMAKE_BUILD_TYPE )
find_package( Qt5Widgets QUIET )
find_package( Qt5Network QUIET )
option( FORCE_QT4 "whether to use Qt4 even if Qt5 is found" )
if( Qt5Widgets_FOUND AND Qt5Network_FOUND )
if( FORCE_QT4 )
message( "************************************************************" )
message( "* *" )
message( "* Qt5 found, but using Qt4 because FORCE_QT4 flag was set. *" )
message( "* *" )
message( "************************************************************" )
set( QT_QMAKE_CHANGED True )
else( FORCE_QT4 )
message( "******************************************************" )
message( "* *" )
message( "* Qt5 found. Using Qt ${Qt5Core_VERSION_STRING}. *" )
message( "* Set FORCE_QT4 flag if you want to use Qt4 instead. *" )
message( "* *" )
message( "******************************************************" )
set( USE_QT5 True )
endif( FORCE_QT4 )
else( Qt5Widgets_FOUND AND Qt5Network_FOUND )
message( "*****************************" )
message( "* *" )
message( "* Qt5 not found. Using Qt4. *" )
message( "* *" )
message( "*****************************" )
endif( Qt5Widgets_FOUND AND Qt5Network_FOUND )
if( NOT USE_QT5 )
find_package( Qt4 4.7 REQUIRED QtCore QtGui QtNetwork )
include( ${QT_USE_FILE} )
endif( NOT USE_QT5 )
find_package( PkgConfig REQUIRED )
find_package( JPEG REQUIRED )
pkg_check_modules( GLIB2 REQUIRED glib-2.0>=2.18 )
pkg_check_modules( LCMS2 REQUIRED lcms2 )
pkg_check_modules( EXIV2 REQUIRED exiv2>=0.19 )
pkg_check_modules( LQR REQUIRED lqr-1>=0.4.1 )
pkg_check_modules( LENSFUN REQUIRED lensfun>=0.2.5 )
pkg_check_modules( GM REQUIRED GraphicsMagick++>=1.3.12 )
pkg_check_modules( GMW REQUIRED GraphicsMagickWand>=1.3.12 )
pkg_check_modules( FFTW3 REQUIRED fftw3>=3.2.2 )
if( ${WITH_GIMP} )
pkg_check_modules( GIMP REQUIRED gimp-2.0>=2.6.10 )
pkg_check_modules( GTK2 REQUIRED gtk+-2.0 )
endif( ${WITH_GIMP} )
# If no .hg, then we can assume we are building from a "clean" source archive previously created
# by 'make package_source' from a hg repo, and named via this process.
if( EXISTS ${PROJECT_SOURCE_DIR}/.hg )
# Determine Photivo version with mercurial. Use current date if mercurial is unavailable.
find_program( MERCURIAL hg )
if( MERCURIAL )
execute_process( COMMAND hg branch OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BRANCH )
execute_process( COMMAND hg log --limit 1 --branch ${BRANCH} --template {date|shortdate}
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE REVDATE )
execute_process( COMMAND hg identify --id OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE REVISION )
execute_process( COMMAND hg identify -n OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PACKREVISION )
set( APPVERSION "${REVDATE} (rev ${REVISION})" )
string( REGEX REPLACE [+] "" REVISION ${REVISION} )
string( REGEX REPLACE [+] "" PACKREVISION ${PACKREVISION} )
else( MERCURIAL )
message( WARNING "Could not call Mercurial to determine Photivo's version info, using current date/time instead." )
execute_process( COMMAND date +%c OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE DATE )
set( APPVERSION "compiled at ${DATE}" )
endif( MERCURIAL )
else( EXISTS ${PROJECT_SOURCE_DIR}/.hg )
message( "\nNo hg metadata is found. Determine Photivo version from the directory name." )
string( REGEX REPLACE ".*photivo-" "rev " APPVERSION ${PROJECT_SOURCE_DIR} )
endif( EXISTS ${PROJECT_SOURCE_DIR}/.hg )
message( "\nBuilding Photivo ${APPVERSION}\n" )
# Choose Photivo parts to be built.
option( WITH_CLEAR "whether to build ptClear" ON )
option( WITH_GIMP "whether to build Gimp plugin" )
option( WITH_ADOBE_PROFILES "whether to build Adobe profiles creator" )
message( "Build Photivo : ON" )
message( "Build ptClear : ${WITH_CLEAR}" )
message( "Build Gimp plugin : ${WITH_GIMP}" )
message( "Build Adobe profiles creator : ${WITH_ADOBE_PROFILES}\n" )
set( CMAKE_CXX_FLAGS "" )
set( CMAKE_C_FLAGS "" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -fopenmp -std=gnu++0x" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -std=gnu++0x" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=gnu++0x" )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Sources
${CMAKE_CURRENT_BINARY_DIR}
${QT4_INCLUDES}
${GLIB2_INCLUDE_DIRS}
${JPEG_INCLUDE_DIR}
${EXIV2_INCLUDE_DIRS}
${LCMS2_INCLUDE_DIRS}
${LQR_INCLUDE_DIRS}
${LENSFUN_INCLUDE_DIRS}
${GM_INCLUDE_DIRS}
${GMW_INCLUDE_DIRS}
${FFTW3_INCLUDE_DIRS}
)
link_directories( ${GLIB2_LIBRARY_DIRS}
${JPEG_LIBRARY_DIRS}
${EXIV2_LIBRARY_DIRS}
${LCMS2_LIBRARY_DIRS}
${LQR_LIBRARY_DIRS}
${LENSFUN_LIBRARY_DIRS}
${GM_LIBRARY_DIRS}
${GMW_LIBRARY_DIRS}
${FFTW3_LIBRARY_DIRS}
)
set( photivo_MOC_HDRS
)
set( photivo_SRCS
)
if( WIN32 )
set( photivo_SRCS
${photivo_SRCS}
Sources/ptEcWin7.cpp
Sources/ptWinApi.cpp
)
endif( WIN32 )
set( photivo_UI_HDRS
)
set( photivo_RCCS
qrc/photivo.qrc
)
if( USE_QT5 )
set(CMAKE_AUTOMOC ON)
qt5_wrap_ui( photivo_UI_SRCS ${photivo_UI_HDRS} )
qt5_add_resources( photivo_RCC_SRCS ${photivo_RCCS} )
add_executable( photivo
${photivo_SRCS}
${photivo_UI_SRCS}
${photivo_RCC_SRCS}
)
qt5_use_modules( photivo Widgets Network )
else( USE_QT5 )
QT4_WRAP_UI( photivo_UI_SRCS ${photivo_UI_HDRS} )
QT4_WRAP_CPP( photivo_MOC_SRCS ${photivo_MOC_HDRS} )
QT4_ADD_RESOURCES( photivo_RCC_SRCS ${photivo_RCCS} )
add_executable( photivo
${photivo_SRCS}
${photivo_MOC_SRCS}
${photivo_UI_SRCS}
${photivo_RCC_SRCS}
)
endif( USE_QT5 )
if( NOT ${CMAKE_SYSTEM_PROCESSOR} OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
set_target_properties( photivo PROPERTIES COMPILE_FLAGS
"-ffast-math -DAPPVERSION='${APPVERSION}' -DPREFIX=${CMAKE_INSTALL_PREFIX}" )
else( NOT ${CMAKE_SYSTEM_PROCESSOR} OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
set_target_properties( photivo PROPERTIES COMPILE_FLAGS
"-march=i686 -ffast-math -DAPPVERSION='${APPVERSION}' -DPREFIX=${CMAKE_INSTALL_PREFIX}" )
endif( NOT ${CMAKE_SYSTEM_PROCESSOR} OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
set_target_properties( photivo PROPERTIES LINK_FLAGS "-lgomp" )
target_link_libraries( photivo
${GLIB2_LIBRARIES}
${QT_LIBRARIES}
${JPEG_LIBRARIES}
${EXIV2_LIBRARIES}
${LCMS2_LIBRARIES}
${LQR_LIBRARIES}
${LENSFUN_LIBRARIES}
${GM_LIBRARIES}
${GMW_LIBRARIES}
${FFTW3_LIBRARIES}
)
install( TARGETS photivo DESTINATION bin )
install( FILES qrc/photivo-appicon.png DESTINATION share/pixmaps )
install( FILES ReferenceMaterial/photivo.desktop DESTINATION share/applications )
install( DIRECTORY ChannelMixers DESTINATION share/photivo )
install( DIRECTORY Curves DESTINATION share/photivo )
install( DIRECTORY LensfunDatabase DESTINATION share/photivo )
install( DIRECTORY Presets DESTINATION share/photivo )
install( DIRECTORY Profiles DESTINATION share/photivo )
install( DIRECTORY Themes DESTINATION share/photivo )
install( DIRECTORY Translations DESTINATION share/photivo )
install( DIRECTORY UISettings DESTINATION share/photivo )
if( ${WITH_CLEAR} )
add_executable( ptClear Sources/ptClear.cpp )
if( USE_QT5 )
qt5_use_modules( ptClear Widgets )
endif( USE_QT5 )
target_link_libraries( ptClear ${QT_LIBRARIES} )
install( TARGETS ptClear DESTINATION bin )
endif( ${WITH_CLEAR} )
if( ${WITH_GIMP} )
include_directories( ${GIMP_INCLUDE_DIRS} ${GTK2_INCLUDE_DIRS} )
link_directories( ${GIMP_LIBRARY_DIRS} ${GTK2_LIBRARY_DIRS} )
add_executable( ptGimp Sources/ptCalloc.cpp
Sources/ptError.cpp
Sources/ptGimp.cpp )
if( USE_QT5 )
qt5_use_modules( ptGimp Core )
endif( USE_QT5 )
set_target_properties( ptGimp PROPERTIES COMPILE_FLAGS "-ffast-math" )
target_link_libraries( ptGimp ${QT_LIBRARIES} ${GTK2_LIBRARIES} ${GIMP_LIBRARIES} )
find_library( LIBGIMP gimp-2.0 )
string( REGEX MATCH "lib[0-9]*" LIBPATH ${LIBGIMP} )
install( TARGETS ptGimp DESTINATION ${LIBPATH}/gimp/2.0/plug-ins )
install( PROGRAMS "mm extern photivo.py" DESTINATION ${LIBPATH}/gimp/2.0/plug-ins )
endif( ${WITH_GIMP} )
if( ${WITH_ADOBE_PROFILES} )
add_executable( ptCreateAdobeProfiles Sources/ptCreateAdobeProfiles.cpp )
target_link_libraries( ptCreateAdobeProfiles ${QT_LIBRARIES} ${LCMS2_LIBRARIES} )
install( TARGETS ptCreateAdobeProfiles DESTINATION bin )
endif( ${WITH_ADOBE_PROFILES} )
# uninstall target
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY )
add_custom_target( uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake )
set( CPACK_SOURCE_IGNORE_FILES "build.*/;BUILD.*/;\\\\.hg/;\\\\.hgignore$;\\\\.hgtags$" )
set( CPACK_PACKAGE_FILE_NAME "photivo-${PACKREVISION}_${REVISION}_${CMAKE_SYSTEM_PROCESSOR}" )
set( CPACK_SOURCE_PACKAGE_FILE_NAME "photivo-${PACKREVISION}_${REVISION}" )
set( CPACK_GENERATOR TBZ2 )
set( CPACK_SOURCE_GENERATOR TBZ2 )
include( CPack )