-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
302 lines (255 loc) · 9.23 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
cmake_minimum_required (VERSION 2.6)
if (NOT DEBUG)
if ( CMAKE_BUILD_TYPE STREQUAL Debug )
set (DEBUG 1)
else ( CMAKE_BUILD_TYPE STREQUAL Debug )
set (DEBUG 0)
endif ( CMAKE_BUILD_TYPE STREQUAL Debug )
endif (NOT DEBUG)
if (NOT PROJECT_PORTABLE)
set (PROJECT_PORTABLE 0)
endif ()
if (NOT NOT_INSTALL_PROJECT_DOCS)
set (NOT_INSTALL_PROJECT_DOCS NO)
endif ()
IF (WIN32)
IF ( PROJECT_PORTABLE STREQUAL 1 )
set (EXE_ADD_PORTABLE -portable)
ENDIF ()
if (NOT VCREDIST_DIR)
set (VCREDIST_DIR "C:/Program Files/Microsoft SDKs/Windows/v7.1/Redist/VC" )
endif ()
if (NOT NSIS_DIR)
set (NSIS_DIR "c:/Program Files (x86)/NSIS")
endif (NOT NSIS_DIR)
ENDIF (WIN32)
set (PROJECT_NAME basketpwd)
set (PROJECT ${PROJECT_NAME})
set (LIB_PROJECT basketlib)
set (BPROJECT_VERSION 0.4.8)
set (HEADERS
src/aboutdialog.h
src/changepassword.h
src/mainwindow.h
src/settingsdialog.h
model/basketmodel.h
src/basketcommon.h
src/passwordwidget.h)
set (SOURCES
src/aboutdialog.cpp
src/changepassword.cpp
src/main.cpp
src/mainwindow.cpp
src/settingsdialog.cpp
model/basketmodel.cpp
src/basketcommon.cpp
src/passwordwidget.cpp)
set (FORMS
ui/aboutdialog.ui
ui/mainwindow.ui
ui/changepassword.ui
ui/settingsdialog.ui)
set (LIB_HEADERS
libs/basketpwd/basketbaseitem.h
libs/basketpwd/basketutils.h
libs/basketpwd/coreplugin.h)
set (LIB_SOURCES
libs/basketpwd/basketbaseitem.cpp
libs/basketpwd/basketutils.cpp
libs/basketpwd/coreplugin.cpp)
set (LANG_PATH l10n)
set (LANGUAGES en)
set (RESOURCES basketpwd.qrc icon-images.qrc)
set (TRANSLATIONS_BINARY qt_ru.qm)
set (DESKTOP_FILE tools/${PROJECT}.desktop)
set (ICON_DEST_PATH share/icons/hicolor)
set (ICON_SIZES
16x16
22x22
32x32
48x48
64x64
128x128
256x256)
set (DOCS ChangeLog.txt README)
set (MACOSX_NAME "Basket of passwords")
set (MACOSX_BUNDLE_NAME ${MACOSX_NAME}.app)
set (QT_USE_QTXML TRUE)
set (QT_USE_QTNETWORK FALSE)
project (${PROJECT})
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
include_directories (model src ${CMAKE_CURRENT_BINARY_DIR})
if (WIN32)
find_package (Qt4 COMPONENTS QtMain QtCore QtGui QtXml REQUIRED)
else (WIN32)
find_package (Qt4 COMPONENTS QtCore QtGui QtXml REQUIRED)
endif (WIN32)
find_package (OpenSSL REQUIRED)
include (${QT_USE_FILE})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_cpp (MOC_LIB_SOURCES ${LIB_HEADERS})
qt4_wrap_ui (UI_SOURCES ${FORMS})
IF(APPLE)
INCLUDE_DIRECTORIES ( /Developer/Headers/FlatCarbon )
FIND_LIBRARY(CARBON_LIBRARY Carbon)
MARK_AS_ADVANCED (CARBON_LIBRARY)
SET(EXTRA_LIBS ${CARBON_LIBRARY})
ENDIF(APPLE)
foreach (LANGUAGE ${LANGUAGE})
set (TS ${LANG_PATH}/${LANGUAGE}.ts)
set (QM ${LANG_PATH}/${LANGUAGE}.qm)
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (
OUTPUT ${QM}
COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS}
MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (
translations
COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
add_custom_command (
TARGET translations
COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
IF(APPLE)
add_custom_target (
clean-mac-bundle
rm -rf ${MACOSX_BUNDLE_NAME}
)
add_custom_target (
mac-pre-bundle
DEPENDS ${PROJECT} clean-mac-bundle
# make a dirs
COMMAND mkdir -p ${MACOSX_BUNDLE_NAME}/Contents/
COMMAND mkdir -p ${MACOSX_BUNDLE_NAME}/Contents/MacOS
COMMAND mkdir -p ${MACOSX_BUNDLE_NAME}/Contents/Resources
# copy binary and plist-files
COMMAND install -m 0755 -p ${PROJECT} ${MACOSX_BUNDLE_NAME}/Contents/MacOS/${MACOSX_NAME}
# contents
COMMAND install -m 0644 -p ${CMAKE_CURRENT_SOURCE_DIR}/tools/Info.plist ${MACOSX_BUNDLE_NAME}/Contents/Info.plist
COMMAND install -m 0644 -p ${CMAKE_CURRENT_SOURCE_DIR}/tools/PkgInfo ${MACOSX_BUNDLE_NAME}/Contents/PkgInfo
# resources
COMMAND install -m 0644 -p ${CMAKE_CURRENT_SOURCE_DIR}/icons/basketpwd.icns ${MACOSX_BUNDLE_NAME}/Contents/Resources/basketpwd.icns
COMMAND cp -R ${CMAKE_CURRENT_SOURCE_DIR}/tools/mac_resource/* ${MACOSX_BUNDLE_NAME}/Contents/Resources/
)
add_custom_target (
mac-bundle
DEPENDS mac-pre-bundle
COMMAND macdeployqt ${MACOSX_BUNDLE_NAME}
)
set(DMG_DIR "${CMAKE_BINARY_DIR}/build-dmg/${PROJECT_NAME}-${BPROJECT_VERSION}")
set(BUNDLE_DIR "${CMAKE_BINARY_DIR}/Basket of passwords.app")
set(DMG_NAME "${PROJECT_NAME}-${BPROJECT_VERSION}.dmg")
add_custom_target (
mac-dmg
DEPENDS mac-dmg-clean mac-bundle
COMMAND mkdir -p ${DMG_DIR}
COMMAND cp -R ${BUNDLE_DIR} ${DMG_DIR}/
COMMAND ln -sf /Applications ${DMG_DIR}
COMMAND cp ${CMAKE_SOURCE_DIR}/icons/${PROJECT_NAME}.icns .VolumeIcon.icns
COMMAND hdiutil create ${CMAKE_BINARY_DIR}/${DMG_NAME} -srcfolder ${DMG_DIR}
DEPENDS ${PROJECT_NAME}
COMMENT "Create DMG image"
#COMMAND macdeployqt ${MACOSX_BUNDLE_NAME} -dmg
)
add_custom_target (
mac-dmg-clean
COMMAND rm -rf ${DMG_DIR}
COMMAND rm -rf ${DMG_NAME}
)
ENDIF (APPLE)
# Make a windows installer
IF ( WIN32 )
file(MAKE_DIRECTORY vcredist)
IF ( CMAKE_SIZEOF_VOID_P STREQUAL 4 )
set (PROJECT_ARCH 86)
set (PROJECT_ARCH_BIT 32)
ELSEIF ( CMAKE_SIZEOF_VOID_P STREQUAL 8 )
set (PROJECT_ARCH 64)
set (PROJECT_ARCH_BIT 64)
ELSE ()
message( FATAL_ERROR "Architecture may not be checked!")
ENDIF ()
IF ( EXISTS "${VCREDIST_DIR}/vcredist_x${PROJECT_ARCH}.exe" )
message(STATUS "Microsoft Visual C++ Redistributable Package (${VCREDIST_DIR}/vcredist_x${PROJECT_ARCH}.exe) found.")
IF ( EXISTS "${NSIS_DIR}/makensis.exe" )
message(STATUS "Nullsoft Scriptable Install System (${NSIS_DIR}/makensis.exe) found.")
configure_file (
"${PROJECT_SOURCE_DIR}/tools/nsis/basketpwd.nsi.in"
"${PROJECT_BINARY_DIR}/basketpwd.nsi"
@ONLY
NEWLINE_STYLE WIN32
)
add_custom_target (
nsis
DEPENDS ${PROJECT} ${LIB_PROJECT} qt-libs
COMMAND "${NSIS_DIR}/makensis.exe" "${PROJECT_BINARY_DIR}/basketpwd.nsi"
)
ELSE ( EXISTS "${NSIS_DIR}/makensis.exe" )
message(STATUS "Nullsoft Scriptable Install System (makensis.exe) not found.")
ENDIF ( EXISTS "${NSIS_DIR}/makensis.exe" )
add_custom_target (
qt-libs
COMMAND ${CMAKE_COMMAND} -E copy ${QT_BINARY_DIR}/QtCore4.dll ${PROJECT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${QT_BINARY_DIR}/QtGui4.dll ${PROJECT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${QT_BINARY_DIR}/QtXml4.dll ${PROJECT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${OPENSSL_ROOT_DIR}/bin/libeay32.dll ${PROJECT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${VCREDIST_DIR}/vcredist_x${PROJECT_ARCH}.exe ${PROJECT_BINARY_DIR}
)
ELSE ( EXISTS "${VCREDIST_DIR}/vcredist_x${PROJECT_ARCH}.exe" )
message(STATUS "Microsoft Visual C++ Redistributable Package (vcredist_x${PROJECT_ARCH}.exe) not found.")
ENDIF ( EXISTS "${VCREDIST_DIR}/vcredist_x${PROJECT_ARCH}.exe" )
ENDIF ( WIN32 )
include_directories(libs ${OPENSSL_INCLUDE_DIR})
source_group ("Header Files" FILES ${HEADERS} ${LIB_HEADERS})
source_group ("Source Files" FILES ${SOURCES} ${LIB_SOURCES})
source_group ("Forms Files" FILES ${UI_SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES} ${MOC_LIB_SOURCES})
source_group ("Resource Files" FILES ${QRC_SOURCES})
if (WIN32)
add_library (${LIB_PROJECT} SHARED ${LIB_HEADERS} ${LIB_SOURCES} ${MOC_LIB_SOURCES})
set (GUI_TYPE WIN32)
set (RC_FILE ${PROJECT_SOURCE_DIR}/basketpwd.rc)
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT}.o
COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT}.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT}.o )
set (RC_FILE ${PROJECT_SOURCE_DIR}/basketpwd.rc)
elseif (APPLE)
add_library (${LIB_PROJECT} ${LIB_HEADERS} ${LIB_SOURCES} ${MOC_LIB_SOURCES})
# set(GUI_TYPE MACOSX_BUNDLE)
else ()
add_library (${LIB_PROJECT} ${LIB_HEADERS} ${LIB_SOURCES} ${MOC_LIB_SOURCES})
endif (WIN32)
add_executable (${PROJECT} ${GUI_TYPE} ${HEADERS} ${SOURCES} ${UI_SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS} ${RC_FILE})
set_target_properties(${LIB_PROJECT} PROPERTIES DEFINE_SYMBOL BASKETPWD_LIBRARY)
target_link_libraries (${LIB_PROJECT} ${QT_LIBRARIES} ${OPENSSL_LIBRARIES})
target_link_libraries (${PROJECT} ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${LIB_PROJECT} ${EXTRA_LIBS})
if (UNIX AND NOT APPLE)
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
install (TARGETS ${LIB_PROJECT} DESTINATION lib${LIB_SUFFIX})
install(FILES ${DESKTOP_FILE} DESTINATION share/applications)
IF ( NOT_INSTALL_PROJECT_DOCS )
message(STATUS "Don't install project documentation")
ELSE ( NOT_INSTALL_PROJECT_DOCS )
install (FILES ${DOCS} DESTINATION share/doc/${PROJECT}-${BPROJECT_VERSION})
ENDIF ( NOT_INSTALL_PROJECT_DOCS )
foreach (ICON_SIZE ${ICON_SIZES})
install (
FILES icons/oxygen-internal/${ICON_SIZE}/${PROJECT_NAME}.png
DESTINATION share/icons/hicolor/${ICON_SIZE}/apps)
endforeach ()
install (
FILES icons/${PROJECT}.svg
DESTINATION ${ICON_DEST_PATH}/scalable/apps
)
foreach (LIB_HEADER ${LIB_HEADERS})
install (
FILES ${LIB_HEADER}
DESTINATION include/basketpwd
)
endforeach()
endif (UNIX AND NOT APPLE)