Repository navigation
Expand file tree
/
Copy pathPackaging.cmake
More file actions
231 lines (218 loc) · 12.5 KB
/
Copy pathPackaging.cmake
File metadata and controls
231 lines (218 loc) · 12.5 KB
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
# SPDX-License-Identifier: MIT
# Windows installer: install rules and CPack. After a release build,
# cmake --build --preset dev --target package
# (or `cpack --config build/dev/CPackConfig.cmake` in the build tree) makes
# mitcad-<version>-windows-x64.exe NSIS installer (needs makensis)
# mitcad-<version>-windows-x64.zip the same files without an installer
# in the build directory. docs/development.md#windows-installer describes
# the toolchain and tools/installer-windows-test.ps1 tests the result; the
# target update-manifest signs a release for the automatic updates
# (docs/updates.md).
if(NOT WIN32)
return()
endif()
# A build with a user's own OptiX worker (mitcad#1332, cmake/RenderOptix.cmake)
# makes no installer: MitCad never ships OptiX.
get_property(mitcad_render_optix GLOBAL PROPERTY MITCAD_RENDER_OPTIX)
if(mitcad_render_optix)
return()
endif()
# file(GET_RUNTIME_DEPENDENCIES) matches its regexes against normalized paths.
if(POLICY CMP0207)
cmake_policy(SET CMP0207 NEW)
endif()
# --- Files ---------------------------------------------------------------
install(TARGETS mitcad mitcad-cli
RUNTIME_DEPENDENCY_SET mitcad_runtime
RUNTIME DESTINATION bin)
# The automatic updates' installer step (mitcad#9); system DLLs only.
install(TARGETS mitcad-updater RUNTIME DESTINATION bin)
install(TARGETS mitcad-mcp-launcher RUNTIME DESTINATION bin)
# Explorer's thumbnails of designs (mitcad#1695, app/thumbnails): the
# thumbnail handler, which the installer registers for .mitcad
# (packaging/windows/filetype.nsh). A module: system DLLs and the C++
# runtime only, which bin has.
install(TARGETS mitcad-thumbnails LIBRARY DESTINATION bin RUNTIME DESTINATION bin)
# The render worker (docs/rendering.md) next to mitcad, where the
# application looks for it, with its libraries: vcpkg's and Open Image
# Denoise's through the runtime dependencies below, and Open Image
# Denoise's CPU device, which its core loads at run time from its folder.
install(TARGETS mitcad-render RUNTIME_DEPENDENCY_SET mitcad_runtime RUNTIME DESTINATION bin)
get_property(mitcad_oidn_dlls GLOBAL PROPERTY MITCAD_OIDN_DLLS)
install(FILES ${mitcad_oidn_dlls} DESTINATION bin)
set(mitcad_runtime_directories "${MITCAD_RENDER_DEPS}/install/oidn/bin")
# The GPU devices' kernels (build-cycles.ps1 -Cuda, mitcad#202) where the
# worker looks for them: cycles\lib next to it, as in the build folder.
get_property(mitcad_cycles_kernels GLOBAL PROPERTY MITCAD_CYCLES_KERNELS)
if(mitcad_cycles_kernels)
install(FILES ${mitcad_cycles_kernels} DESTINATION bin/cycles/lib)
endif()
# Qt's DLLs and plugins (platforms/qwindows.dll, styles, image formats, the
# SVG icon engine) through windeployqt. The software OpenGL (opengl32sw.dll)
# is left out on purpose: OCCT calls the system's opengl32.dll, and a Qt
# context from the software renderer would be unusable for it. The compiler
# runtime comes from INSTALL_REQUIRED_SYSTEM_LIBRARIES below.
qt_generate_deploy_app_script(
TARGET mitcad
OUTPUT_SCRIPT mitcad_qt_deploy_script
NO_TRANSLATIONS
NO_COMPILER_RUNTIME
DEPLOY_TOOL_OPTIONS --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler)
install(SCRIPT "${mitcad_qt_deploy_script}")
# Insert > Component from Web's web browser component (mitcad#1579: the
# module mitcad-webbrowser and CEF's runtime) is not in the installer: it is
# a package of its own, downloaded on first use (app/webbrowser/CMakeLists.txt).
# The DLLs the executables load: Qt (windeployqt adds its plugins to them),
# OCCT and what OCCT needs (FreeType, libpng, ...) from vcpkg. The system's
# DLLs and the Mesa copy of a development build are not part of a release.
set(mitcad_vcpkg_prefix "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(mitcad_vcpkg_bin "${mitcad_vcpkg_prefix}/debug/bin")
else()
set(mitcad_vcpkg_bin "${mitcad_vcpkg_prefix}/bin")
endif()
install(RUNTIME_DEPENDENCY_SET mitcad_runtime
PRE_EXCLUDE_REGEXES [[api-ms-win-.*]] [[ext-ms-.*]]
[[opengl32\.dll]] [[libgallium_wgl\.dll]]
POST_EXCLUDE_REGEXES [[.*[/\\][Ss]ystem32[/\\].*]] [[.*[/\\]Windows[/\\].*]]
DIRECTORIES "${mitcad_vcpkg_bin}" "$<TARGET_FILE_DIR:Qt6::Core>" ${mitcad_runtime_directories}
DESTINATION bin)
# The Visual C++ runtime (vcruntime140*.dll, msvcp140*.dll, ...) next to the
# executables; the installer does not depend on a separate redistributable.
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
set(CMAKE_INSTALL_UCRT_LIBRARIES FALSE)
include(InstallRequiredSystemLibraries)
# --- Licences ------------------------------------------------------------
# Mitcad's own licence, the bundled font and, from vcpkg, the licence text of
# every ported library that ends up in bin (OCCT, FreeType, libpng, ...).
install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION .)
install(FILES "${PROJECT_SOURCE_DIR}/packaging/windows/THIRD-PARTY-NOTICES.txt" DESTINATION .)
install(FILES "${PROJECT_SOURCE_DIR}/third_party/fonts/droid-sans/LICENSE.txt"
DESTINATION licenses/droid-sans)
# The annotations' technical lettering (mitcad#902): a file of its own in
# bin/fonts beside mitcad.exe, loaded at run time (LGPL-3.0 with the font
# exception).
if(EXISTS "${PROJECT_SOURCE_DIR}/third_party/fonts/iso-lettering/lettering.ttf")
install(FILES "${PROJECT_SOURCE_DIR}/third_party/fonts/iso-lettering/lettering.ttf" DESTINATION bin/fonts)
install(FILES "${PROJECT_SOURCE_DIR}/third_party/fonts/iso-lettering/LICENSE.txt" DESTINATION licenses/iso-lettering)
endif()
# The interface languages (mitcad#1460, cmake/Translations.cmake): MitCad's
# catalogues and Qt's own (qtbase_<code>.qm, BSD-3-Clause) in bin/translations
# beside mitcad.exe, where Language.cpp looks; never the tests'
# pseudo-language.
get_property(mitcad_translation_files GLOBAL PROPERTY MITCAD_TRANSLATION_FILES)
if(mitcad_translation_files)
install(FILES ${mitcad_translation_files} DESTINATION bin/translations)
endif()
# three.js, embedded for the web viewer (app/web/viewer).
install(FILES "${PROJECT_SOURCE_DIR}/third_party/three/LICENSE" DESTINATION licenses/three)
# The bundled material dataset (mitcad#1213), compiled into the model as data.
install(FILES "${PROJECT_SOURCE_DIR}/third_party/material-properties/LICENSE"
"${PROJECT_SOURCE_DIR}/third_party/material-properties/NOTICE"
DESTINATION licenses/material-properties)
# SolidCraft's format upgrade steps, adapted for the .solidcraft import (third_party/solidcraft).
install(FILES "${PROJECT_SOURCE_DIR}/third_party/solidcraft/LICENSE-MIT" DESTINATION licenses/solidcraft)
# QtKeychain, linked statically (cmake/Keychain.cmake).
install(FILES "${MITCAD_QTKEYCHAIN_LICENSE}" DESTINATION licenses/qtkeychain)
install(DIRECTORY "${mitcad_vcpkg_prefix}/share/"
DESTINATION licenses/vcpkg
FILES_MATCHING PATTERN "copyright")
# The render worker's libraries that do not come from vcpkg (build-cycles.ps1's
# prefix): Cycles with the licences of the code it bundles, and Open Image
# Denoise.
set(mitcad_render_install "${MITCAD_RENDER_DEPS}/install")
install(FILES "${mitcad_render_install}/cycles/LICENSE" DESTINATION licenses/cycles)
install(DIRECTORY "${mitcad_render_install}/cycles/licenses/" DESTINATION licenses/cycles)
install(FILES "${mitcad_render_install}/oidn/share/doc/OpenImageDenoise/LICENSE.txt"
"${mitcad_render_install}/oidn/share/doc/OpenImageDenoise/third-party-programs.txt"
DESTINATION licenses/openimagedenoise)
# --- CPack ---------------------------------------------------------------
# The names people read say MitCad (mitcad#822). The install folder, and with
# it the uninstall entry's key (CPACK_PACKAGE_INSTALL_REGISTRY_KEY), keeps
# "Mitcad", which the updater and the uninstaller look for; the vendor's key
# Software\<vendor> is the same key in either spelling (the registry ignores
# case).
set(CPACK_PACKAGE_NAME "MitCad")
set(CPACK_PACKAGE_VENDOR "MitCad developers")
set(CPACK_PACKAGE_CONTACT "MitCad developers <devs@mitcad.org>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(mitcad_package_name "mitcad-${PROJECT_VERSION}-windows-x64")
set(CPACK_PACKAGE_FILE_NAME "${mitcad_package_name}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Mitcad")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_GENERATOR "NSIS;ZIP")
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)
# Only the CMake-installed files; never the build tree's Mesa or PDB files.
set(CPACK_STRIP_FILES OFF)
# NSIS, with an installer script of our own (packaging/windows/NSIS.template.in,
# which CPack finds in CPACK_MODULE_PATH; mitcad#118): installs just for the
# current user (the default, no elevation) or for all users (Program Files,
# elevation), with the Start menu shortcut, "run MitCad" on the last page,
# the .mitcad file type and an uninstall of an earlier version in the same
# scope before the new one is put in.
set(CPACK_MODULE_PATH "${PROJECT_SOURCE_DIR}/packaging/windows" ${CMAKE_MODULE_PATH})
set(CPACK_NSIS_DISPLAY_NAME "MitCad ${PROJECT_VERSION}")
set(CPACK_NSIS_PACKAGE_NAME "MitCad")
set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\mitcad.exe")
set(CPACK_PACKAGE_EXECUTABLES "mitcad" "MitCad")
# NSIS wants backslashes; CPackConfig.cmake is parsed again, so they are doubled.
string(REPLACE "/" "\\\\" mitcad_nsis_filetype "${PROJECT_SOURCE_DIR}/packaging/windows/filetype.nsh")
string(REPLACE "/" "\\\\" mitcad_nsis_icon "${PROJECT_SOURCE_DIR}/app/branding/mitcad.ico")
set(CPACK_NSIS_MUI_ICON "${mitcad_nsis_icon}")
set(CPACK_NSIS_MUI_UNIICON "${mitcad_nsis_icon}")
set(CPACK_NSIS_DEFINES "!include '${mitcad_nsis_filetype}'")
# A thumbnail handler Explorer still holds is moved aside before the files
# are put in place (mitcad#1695, filetype.nsh).
set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "!insertmacro MitcadThumbnailsMoveAside")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "!insertmacro MitcadFileTypeRegister")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "!insertmacro MitcadFileTypeUnregister")
include(CPack)
# --- Update manifest -----------------------------------------------------
# The automatic updates' manifest of this release (mitcad#9,
# docs/updates.md), after `package`:
# cmake --build --preset dev --target update-manifest
# signs the installer with the release key and writes update-manifest.json
# next to it, for the GitHub release. The private key is only in the release
# environment: MITCAD_RELEASE_KEY (64 hex digits) or MITCAD_RELEASE_KEY_FILE
# (a file of them), read by mitcad-release when the target runs; never a
# CMake variable or a file of the repository.
set(MITCAD_RELEASE_URL "https://github.com/mitcad/Mitcad/releases" CACHE STRING
"Where releases are published: <url>/download/v<version>/<file>, notes at <url>/tag/v<version>")
# Not CPACK_PACKAGE_FILE_NAME: include(CPack) leaves the source package's name in it.
set(mitcad_installer "${mitcad_package_name}.exe")
if(MITCAD_UPDATE_TEST_HOOKS)
# A test build reads the update tests' variables (mitcad#921): never
# signed as a release.
add_custom_target(update-manifest
COMMAND "${CMAKE_COMMAND}" -E echo
"update-manifest: this build has MITCAD_UPDATE_TEST_HOOKS on; sign a release built without it"
COMMAND "${CMAKE_COMMAND}" -E false
VERBATIM)
else()
add_custom_target(update-manifest
COMMAND "$<TARGET_FILE:mitcad-release>" manifest
--version "${PROJECT_VERSION}"
--notes "${MITCAD_RELEASE_URL}/tag/v${PROJECT_VERSION}"
--asset windows-x64 "${CMAKE_BINARY_DIR}/${mitcad_installer}"
"${MITCAD_RELEASE_URL}/download/v${PROJECT_VERSION}/${mitcad_installer}"
--out "${CMAKE_BINARY_DIR}/update-manifest.json"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Signing ${mitcad_installer}, writing update-manifest.json"
VERBATIM)
add_dependencies(update-manifest mitcad-release)
endif()
# The installer and the automatic update in ctest, with Mesa (a build VM):
# tools/installer-windows-test.ps1 installs just for the current user and
# for all users, updates each installation from a local HTTPS server and
# uninstalls. It changes the registry's .mitcad file type (HKCU and HKLM),
# so it runs only once `package` has made this build's installer; skipped
# otherwise.
if(BUILD_TESTING AND MITCAD_MESA_DIR)
add_test(NAME app.installer-windows
COMMAND powershell -NoProfile -ExecutionPolicy Bypass
-File "${PROJECT_SOURCE_DIR}/tools/installer-windows-test.ps1"
-Build "${CMAKE_BINARY_DIR}" -MesaDir "${MITCAD_MESA_DIR}"
-Out "${CMAKE_BINARY_DIR}/installer-test" -SkipStale)
set_tests_properties(app.installer-windows PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 1800)
endif()