@@ -20,14 +20,31 @@ set(CMAKE_AUTOMOC ON)
20
20
set (CMAKE_AUTORCC ON )
21
21
set (CMAKE_AUTOUIC ON )
22
22
23
- find_package (QT NAMES Qt6 REQUIRED COMPONENTS Core )
23
+ include (GNUInstallDirs )
24
+ # GNU dirs must be adjusted before finding Qt for qt_deploy_runtime_dependencies to use customzied vars
25
+ if (WIN32 )
26
+ set (CMAKE_INSTALL_BINDIR . )
27
+ endif ()
28
+
29
+ # options
30
+ if (WIN32 )
31
+ option (DUMMY_WRITE "Write image to local file named 'dummy_image_file' instead to real device (for testing)" )
32
+ endif ()
24
33
34
+ # dependencies
35
+ find_package (QT NAMES Qt6 REQUIRED COMPONENTS Core )
25
36
set (qtComponents Gui Network Widgets LinguistTools )
26
37
if (LINUX )
27
38
list (APPEND qtComponents DBus )
28
39
endif ()
29
40
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${qtComponents} )
30
41
42
+ if (MSVC_TOOLSET_VERSION EQUAL 142 )
43
+ list (APPEND CMAKE_PREFIX_PATH "windows/msvc2019/zlib" )
44
+ endif ()
45
+ find_package (ZLIB REQUIRED )
46
+
47
+ # executable
31
48
qt_add_executable (LibreELEC.USB-SD.Creator WIN32 MACOSX_BUNDLE
32
49
creator.cpp creator.h creator.ui
33
50
deviceenumerator.h
@@ -58,7 +75,7 @@ target_link_libraries(LibreELEC.USB-SD.Creator PUBLIC
58
75
Qt${QT_VERSION_MAJOR}::Gui
59
76
Qt${QT_VERSION_MAJOR}::Network
60
77
Qt${QT_VERSION_MAJOR}::Widgets
61
- z
78
+ ZLIB::ZLIB
62
79
)
63
80
64
81
string (TIMESTAMP nowDateTime UTC )
@@ -67,6 +84,7 @@ target_compile_definitions(LibreELEC.USB-SD.Creator PRIVATE
67
84
"BUILD_VERSION=\" ${PROJECT_VERSION} \" "
68
85
"COPYRIGHT_YEARS=\" ${copyrightYears} \" "
69
86
$< $< CONFIG:Debug> :ALWAYS_DEBUG_OUTPUT>
87
+ $< $< BOOL:${DUMMY_WRITE} > :WINDOWS_DUMMY_WRITE>
70
88
)
71
89
72
90
qt_add_translations (LibreELEC.USB-SD.Creator
@@ -107,6 +125,12 @@ qt_add_translations(LibreELEC.USB-SD.Creator
107
125
)
108
126
109
127
if (WIN32 )
128
+ if (MSVC )
129
+ set_target_properties (LibreELEC.USB-SD.Creator PROPERTIES
130
+ LINK_OPTIONS "/MANIFEST:NO" # disable default manifest
131
+ )
132
+ endif ()
133
+
110
134
target_sources (LibreELEC.USB-SD.Creator PUBLIC
111
135
deviceenumerator_windows.cpp deviceenumerator_windows.h
112
136
diskwriter_windows.cpp diskwriter_windows.h
@@ -115,6 +139,14 @@ if(WIN32)
115
139
)
116
140
117
141
configure_file ("windows/winapp.rc.in" "${CMAKE_SOURCE_DIR} /windows/winapp.rc" @ONLY )
142
+
143
+ set (qtDeployExecutable "$<TARGET_FILE_NAME:LibreELEC.USB-SD.Creator>" )
144
+ set (qtDeployExtraCommands "
145
+ # windeployqt also packages extra libs that aren't needed
146
+ foreach(dll in Qt${QT_VERSION_MAJOR} Svg opengl32sw D3Dcompiler_47)
147
+ file(REMOVE \"\\\$ {QT_DEPLOY_PREFIX}/\\\$ {QT_DEPLOY_BIN_DIR}/\\\$ {dll}.dll\" )
148
+ endforeach()
149
+ " )
118
150
elseif (APPLE )
119
151
set_target_properties (LibreELEC.USB-SD.Creator PROPERTIES
120
152
OUTPUT_NAME "${projectDisplayName} "
@@ -126,32 +158,24 @@ elseif(APPLE)
126
158
privileges_unix.cpp privileges_unix.h
127
159
)
128
160
129
- set (bundleContentsDir "$<TARGET_BUNDLE_CONTENT_DIR:LibreELEC.USB-SD.Creator>" )
130
161
install (FILES "dmg_osx/icon.icns"
131
- DESTINATION "${bundleContentsDir} /Resources"
162
+ DESTINATION "$<TARGET_BUNDLE_CONTENT_DIR:LibreELEC.USB-SD.Creator> /Resources"
132
163
)
133
164
134
- qt_generate_deploy_script (
135
- TARGET LibreELEC.USB-SD.Creator
136
- OUTPUT_SCRIPT qtDeployScript
137
- CONTENT "
138
- qt_deploy_runtime_dependencies(
139
- EXECUTABLE \" $<TARGET_BUNDLE_DIR:LibreELEC.USB-SD.Creator>\"
140
- GENERATE_QT_CONF
141
- NO_APP_STORE_COMPLIANCE
142
- VERBOSE
143
- )
144
- # macdeployqt also packages extra frameworks that aren't needed
145
- foreach(qtModule in Pdf Svg)
146
- file(REMOVE_RECURSE \" ${bundleContentsDir} /Frameworks/Qt\\\$ {qtModule}.framework\" )
147
- endforeach()
148
-
149
- # codesign
150
- execute_process(COMMAND \" ${CMAKE_SOURCE_DIR} /dmg_osx/codesign.sh\"
151
- WORKING_DIRECTORY \" ${bundleContentsDir} \"
152
- )
153
- " )
154
- install (SCRIPT ${qtDeployScript} )
165
+ set (qtDeployExecutable "$<TARGET_FILE_NAME:LibreELEC.USB-SD.Creator>.app" )
166
+ set (qtDeployExtraCommands "
167
+ set(bundleContentsDir \"\\\$ {QT_DEPLOY_PREFIX}/${qtDeployExecutable} /Contents\" )
168
+
169
+ # macdeployqt also packages extra frameworks that aren't needed
170
+ foreach(qtModule in Pdf Svg)
171
+ file(REMOVE_RECURSE \"\\\$ {bundleContentsDir}/Frameworks/Qt\\\$ {qtModule}.framework\" )
172
+ endforeach()
173
+
174
+ # codesign
175
+ execute_process(COMMAND \" ${CMAKE_SOURCE_DIR} /dmg_osx/codesign.sh\"
176
+ WORKING_DIRECTORY \"\\\$ {bundleContentsDir}\"
177
+ )
178
+ " )
155
179
elseif (LINUX )
156
180
set_target_properties (LibreELEC.USB-SD.Creator PROPERTIES SUFFIX .Linux.bin )
157
181
@@ -166,15 +190,37 @@ elseif(LINUX)
166
190
)
167
191
endif ()
168
192
193
+ # install
169
194
install (TARGETS LibreELEC.USB-SD.Creator
170
195
BUNDLE
171
196
DESTINATION .
172
197
)
198
+ if (qtDeployExecutable )
199
+ qt_generate_deploy_script (
200
+ TARGET LibreELEC.USB-SD.Creator
201
+ OUTPUT_SCRIPT qtDeployScript
202
+ CONTENT "
203
+ qt_deploy_runtime_dependencies(
204
+ EXECUTABLE \" ${qtDeployExecutable} \"
205
+ GENERATE_QT_CONF
206
+ NO_APP_STORE_COMPLIANCE
207
+ NO_COMPILER_RUNTIME
208
+ NO_TRANSLATIONS
209
+ VERBOSE
210
+ )
211
+ ${qtDeployExtraCommands}
212
+ "
213
+ )
214
+ install (SCRIPT ${qtDeployScript} )
215
+ endif ()
173
216
174
217
# cpack
175
218
set (CPACK_PACKAGE_NAME "${projectDisplayName} " )
176
219
set (CPACK_PACKAGE_VENDOR "LibreELEC" )
177
- if (APPLE )
220
+ if (WIN32 )
221
+ set (CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.Win32" )
222
+ set (CPACK_GENERATOR INNOSETUP )
223
+ elseif (APPLE )
178
224
set (CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.macOS" )
179
225
180
226
set (notarizeScript "${CMAKE_BINARY_DIR} /notarize.cmake" )
0 commit comments