forked from luspi/photoqt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
228 lines (178 loc) · 6.7 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
##################################################
# CMakeLists for PhotoQt-QML: http://photoqt.org #
##################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(photoqt)
##################################################################
#### GLOBAL VERSION STRING FOR ALL FILES (INCLUDING CPP/QML) ####
##################################################################
ADD_DEFINITIONS(-DVERSION="1.5.1")
##########################
#### ENABLE AUTOMOC ####
##########################
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#############################
#### GET list of files ####
#############################
INCLUDE(CMake/ListFilesCPlusPlus.cmake)
INCLUDE(CMake/ListFilesQML.cmake)
#############################################
#### OPTIONS THAT CAN BE SET BY THE USER ####
#############################################
OPTION(RAW "Use libraw library" ON)
OPTION(EXIV2 "Use exiv2 library" ON)
OPTION(GM "Use graphicsmagick library" ON)
OPTION(QTONLY "ONLY USE QT-ONLY FEATURES" OFF)
################################################
#### ENABLE C++11 FEATURES AND OPTIMISATION ####
################################################
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -Wall")
################################
#### FIND REQUIRED PACKAGES ####
################################
FIND_PACKAGE(Qt5 COMPONENTS LinguistTools Quick Widgets Core Svg REQUIRED)
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(Magick)
FIND_PACKAGE(Exiv2)
FIND_PACKAGE(LibRaw)
####################################
#### TRANSLATIONS AND RESOURCES ####
####################################
# We first copy the most recent *.ts files to the build directory and then process them
# This way, we don't have to mess with files outside of the build folder
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/buildlang)
FILE(GLOB files "lang/*.ts")
FOREACH(file ${files})
GET_FILENAME_COMPONENT(filename ${file} NAME)
FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/lang/${filename} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/buildlang)
QT5_CREATE_TRANSLATION(qm_files ${photoqt_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/buildlang/${filename} OPTIONS "-no-obsolete")
ENDFOREACH()
# Copy the language QRC file to the output directory, because the files listed in the
# qrc file are relative to that directory.
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lang.qrc
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/lang.qrc ${CMAKE_CURRENT_BINARY_DIR}/lang.qrc
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/lang.qrc
DEPENDS ${qm_files})
# Set resources
INCLUDE(CMake/ListFilesResources.cmake)
QT5_ADD_RESOURCES(RESOURCES ${photoqt_RESOURCES})
######################
#### FINISHING UP ####
######################
# include, add definitions and include dirs
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDES})
ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# And add the executeable (on windows we add application icons...)
IF(WIN32)
ADD_EXECUTABLE(photoqt WIN32 ${photoqt_SOURCES} ${photoqt_HEADERS_MOC} ${RESOURCES} windowsicons.rc)
QT5_USE_MODULES(photoqt Quick Widgets Sql Svg Core Xml WinExtras)
ELSEIF(NOT WIN32)
ADD_EXECUTABLE(photoqt ${photoqt_SOURCES} ${photoqt_HEADERS_MOC} ${RESOURCES})
QT5_USE_MODULES(photoqt Quick Widgets Sql Svg Core Xml)
ENDIF(WIN32)
#Depending on setup, we copy one of the desktop files to photoqt.desktop
IF(GM)
ADD_CUSTOM_COMMAND(TARGET photoqt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/for_photoqt_desktop_FULL ${CMAKE_CURRENT_SOURCE_DIR}/photoqt.desktop)
ELSEIF(NOT GM)
ADD_CUSTOM_COMMAND(TARGET photoqt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/for_photoqt_desktop_QT ${CMAKE_CURRENT_SOURCE_DIR}/photoqt.desktop)
ENDIF(GM)
MESSAGE("")
########################
#### CUSTOM OPTIONS ####
########################
IF(RAW)
IF(NOT ${LIBRAW_FOUND})
MESSAGE(FATAL_ERROR "** Unable to locate LibRaw... is it installed?")
ELSEIF(${LIBRAW_FOUND})
INCLUDE_DIRECTORIES(${LIBRAW_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(photoqt "raw")
MESSAGE("** LibRaw enabled")
ADD_DEFINITIONS(-DRAW)
ENDIF(NOT ${LIBRAW_FOUND})
ELSEIF(NOT RAW)
MESSAGE("** LibRaw DISABLED")
ENDIF(RAW)
IF(EXIV2)
IF(NOT ${EXIV2_FOUND})
MESSAGE(FATAL_ERROR "** Unable to locate Exiv2... is it installed?")
ELSEIF(${EXIV2_FOUND})
INCLUDE_DIRECTORIES(${EXIV2_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(photoqt "exiv2")
IF(WIN32)
TARGET_LINK_LIBRARIES(photoqt "expat")
TARGET_LINK_LIBRARIES(photoqt "ws2_32")
TARGET_LINK_LIBRARIES(photoqt "wsock32")
TARGET_LINK_LIBRARIES(photoqt "z")
TARGET_LINK_LIBRARIES(photoqt "intl")
TARGET_LINK_LIBRARIES(photoqt "iconv")
TARGET_LINK_LIBRARIES(photoqt "psapi")
ENDIF(WIN32)
ADD_DEFINITIONS(-DEXIV2)
MESSAGE("** Exiv2 enabled")
ENDIF(NOT ${EXIV2_FOUND})
ELSEIF(NOT EXIV2)
MESSAGE("** Exiv2 DISABLED")
ENDIF(EXIV2)
IF(GM)
IF(NOT ${MAGICK++_FOUND})
MESSAGE(FATAL_ERROR "** Unable to locate GraphicsMagick... is it installed?")
ELSEIF(${MAGICK++_FOUND})
INCLUDE_DIRECTORIES(${MAGICK++_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(photoqt "GraphicsMagick++")
ADD_DEFINITIONS(-DGM)
MESSAGE("** Graphicsmagick enabled")
ENDIF(NOT ${MAGICK++_FOUND})
ELSEIF(NOT GM)
MESSAGE("** Graphicsmagick DISABLED")
ENDIF(GM)
#######################
#### INSTALL FILES ####
#######################
IF(UNIX)
# Set the install prefix to /usr/
SET(PRODUCT_INSTALL_PREFIX /usr)
# Install executeable
INSTALL(
TARGETS photoqt
DESTINATION bin/
)
# Install desktop file
INSTALL(
FILES photoqt.desktop
DESTINATION share/applications
)
# And install all the icons
INSTALL(
FILES icons/16x16/apps/photoqt.png
DESTINATION share/icons/hicolor/16x16/apps/
)
INSTALL(
FILES icons/32x32/apps/photoqt.png
DESTINATION share/icons/hicolor/32x32/apps/
)
INSTALL(
FILES icons/48x48/apps/photoqt.png
DESTINATION share/icons/hicolor/48x48/apps/
)
INSTALL(
FILES icons/64x64/apps/photoqt.png
DESTINATION share/icons/hicolor/64x64/apps/
)
INSTALL(
FILES icons/128x128/apps/photoqt.png
DESTINATION share/icons/hicolor/128x128/apps/
)
INSTALL(
FILES photoqt.appdata.xml
DESTINATION share/appdata/
)
ENDIF(UNIX)
##########################
#### UNINSTALL TARGET ####
##########################
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/CMake/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)