forked from jimevins/glabels-qt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
230 lines (186 loc) · 6.82 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
cmake_minimum_required (VERSION 3.9)
###############################################################################
# gLabels Label Designer Project
###############################################################################
project (glabels-qt VERSION "3.99.0")
#
# Path for locally defined cmake modules
#
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#=======================================
# Version Information
#=======================================
set (WEBSITE "glabels.org")
set (BUG_WEBSITE "https://github.com/jimevins/glabels-qt/issues")
execute_process(
COMMAND git symbolic-ref --short HEAD
RESULT_VARIABLE BRANCH_VALID
OUTPUT_VARIABLE BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ${BRANCH_VALID} STREQUAL "0")
set (BRANCH "Unkonwn")
endif ()
execute_process(
COMMAND git rev-list --count ${BRANCH}
RESULT_VARIABLE COMMIT_COUNT_VALID
OUTPUT_VARIABLE COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ${COMMIT_COUNT_VALID} STREQUAL "0")
set (COMMIT_COUNT "?")
endif ()
execute_process(
COMMAND git log -1 --format=%h
RESULT_VARIABLE COMMIT_HASH_VALID
OUTPUT_VARIABLE COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ${COMMIT_HASH_VALID} STREQUAL "0")
set (COMMIT_HASH "exported")
endif ()
execute_process(
COMMAND git log -1 --format=%cd --date=short
RESULT_VARIABLE COMMIT_DATE_VALID
OUTPUT_VARIABLE COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ${COMMIT_DATE_VALID} STREQUAL "0")
string (TIMESTAMP COMMIT_DATE %Y-%m-%d)
endif ()
# Uncomment for snapshots, comment for releases
set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-${BRANCH}${COMMIT_COUNT}")
# Uncomment for releases, comment for snapshots
#set(VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(LONG_VERSION_STRING "${VERSION_STRING} (${COMMIT_HASH} ${COMMIT_DATE})")
# Auto-generate version file
configure_file (.version.in VERSION @ONLY)
#=======================================
# Packaging Information
#=======================================
set (CPACK_PACKAGE_VENDOR ${WEBSITE})
set (CPACK_PACKAGE_NAME glabels)
set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set (CPACK_PACKAGE_VERSION_TWEAK ${COMMIT_HASH})
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "gLabels Label Designer")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_EXECUTABLES "glabels-qt;gLabels")
set (CPACK_CREATE_DESKTOP_LINKS "glabels-qt")
set (CPACK_NSIS_DISPLAY_NAME "gLabels")
set (CPACK_NSIS_URL_INFO_ABOUT "http://${WEBSITE}")
set (CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/glabels/windows-icon/glabels.ico")
set (CPACK_NSIS_MODIFY_PATH "ON")
include (CPack)
#=======================================
# Dependencies
#=======================================
if (MINGW)
# Locate MINGW directories
string (REPLACE "/g++.exe" "" MINGW_BIN_DIR ${CMAKE_CXX_COMPILER})
string (REPLACE "/bin" "" MINGW_BASE_DIR ${MINGW_BIN_DIR})
# Make sure we can find MINGW libraries, e.g. zlib
set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} )
endif ()
find_package (Qt5Core 5.4 REQUIRED)
find_package (Qt5Widgets 5.4 REQUIRED)
find_package (Qt5PrintSupport 5.4 REQUIRED)
find_package (Qt5Xml 5.4 REQUIRED)
find_package (Qt5Svg 5.4 REQUIRED)
find_package (Qt5LinguistTools)
if (WIN32)
# Locate Qt directories
execute_process (COMMAND qtpaths --install-prefix OUTPUT_VARIABLE QT_BASE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set (QT_BIN_DIR ${QT_BASE_DIR}/bin)
endif ()
#
# Optional dependencies
#
find_package (ZLIB 1.2 QUIET)
find_package (GnuBarcode 0.98 QUIET)
find_package (LibQrencode 3.4 QUIET)
find_package (LibZint 2.6 EXACT QUIET)
# Unit testing support
find_package (Qt5Test 5.4 QUIET)
#=======================================
# Global compiler options
#=======================================
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
#
# Uncomment to compile everything with aggressively pedantic options
# (not recommended -- only for testing -- also not portable)
#
#add_compile_options("-Wall" "-Werror" "-Wpedantic")
# Uncomment to always compile with debug symbols
add_compile_options("-g")
endif ()
#=======================================
# Unit Testing
#=======================================
if (Qt5Test_FOUND)
enable_testing ()
endif ()
#=======================================
# Subdirectories
#=======================================
add_subdirectory (glbarcode)
add_subdirectory (backends)
add_subdirectory (model)
add_subdirectory (glabels)
add_subdirectory (glabels-batch)
add_subdirectory (templates)
add_subdirectory (user-docs)
add_subdirectory (translations)
add_subdirectory (data)
#=======================================
# Print configuration information
#=======================================
message (STATUS "")
message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME})
message (STATUS "Project version ......... " ${LONG_VERSION_STRING})
message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX})
message (STATUS "Source code location .... " ${glabels_SOURCE_DIR})
message (STATUS "CMake version ........... " ${CMAKE_VERSION})
message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_VERSION})
message (STATUS "Qt version .............. " ${Qt5Core_VERSION})
if (ZLIB_FOUND)
message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING})
else (ZLIB_FOUND)
message (STATUS "zlib (optional).......... No.")
endif (ZLIB_FOUND)
if (GNUBARCODE_FOUND)
message (STATUS "GNU Barcode (optional)... " ${GNUBARCODE_VERSION_STRING})
else (GNUBARCODE_FOUND)
message (STATUS "GNU Barcode (optional)... No.")
endif (GNUBARCODE_FOUND)
if (LIBQRENCODE_FOUND)
message (STATUS "qrencode (optional)...... " ${LIBQRENCODE_VERSION_STRING})
else (LIBQRENCODE_FOUND)
message (STATUS "qrencode (optional)...... No.")
endif (LIBQRENCODE_FOUND)
if (LIBZINT_FOUND)
message (STATUS "libzint (optional)....... " ${LIBZINT_VERSION_STRING})
else (LIBZINT_FOUND)
message (STATUS "libzint (optional)....... No.")
endif (LIBZINT_FOUND)
if (Qt5Test_FOUND)
message (STATUS "QtTest (optional)........ " ${Qt5Test_VERSION})
else (Qt5Test_FOUND)
message (STATUS "QtTest (optional)........ No.")
endif (Qt5Test_FOUND)
if (MSVC)
message (STATUS "MSVC Qt location ........ " ${QT_BASE_DIR})
endif (MSVC)
if (MINGW)
message (STATUS "MinGW location .......... " ${MINGW_BASE_DIR})
message (STATUS "MinGW Qt location ....... " ${QT_BASE_DIR})
endif (MINGW)
message (STATUS "")
#
# Uncomment to print all CMake variables
#
# get_cmake_property(_variableNames VARIABLES)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()