创建 Qt 工程时,我们通常使用 Qt 提供的 Online installer 安装 Qt Creator 和 Qt 库来创建、编译、发布 Qt 项目,这对开发环境和 CI Agent 环境有较强的要求,一旦环境安装不对或者安装时缺少了一些组件,可能导致无法编译出产物。最近一段时间,Qt 也拥抱 Conan,使我们可以通过 Conan 管理 Qt 库,这样我们就可以真正实现一套 CMake 脚本来管理和发布 Qt 的应用了。以下我们将演示如何通过 CMake + Conan 来组织 Qt 工程和实现程序的发布流程。

创建 CMakeLists.txt 和 conanfile.py

我们创建一个简单的工程来显示一个 Qt Widget UI 界面: main_form.h

1
2
3
4
5
6
7
8
#include <QtWidgets/QWidget>

class MainForm : public QWidget {
Q_OBJECT
public:
MainForm(QWidget* parent = 0);
~MainForm();
};

main_form.cc

1
2
3
4
5
6
7
#include "main_form.h"

MainForm::MainForm(QWidget* parent)
: QWidget(parent) {}

MainForm::~MainForm() {}

main.cc

1
2
3
4
5
6
7
8
9
#include <QApplication>
#include "main_form.h"

int main(int argc, char* argv[]) {
QApplication a(argc, argv);
MainForm m;
m.show();
return a.exec();
}

创建 conanfile.py 来引入 Qt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from conans import ConanFile, tools
import platform


class ModuleConan(ConanFile):
name = "QtConanExample"
description = "An example for Qt with Conan"
settings = "os", "compiler", "build_type", "arch"
generators = "qt", "cmake", "cmake_find_package_multi", "cmake_paths"
default_options = {
"qt:shared": True,
"qt:qttools": True
}

def configure(self):
del self.settings.compiler.cppstd

def requirements(self):
if platform.system() == "Windows":
self.requires("qt/5.15.3")
else:
self.requires("qt/6.2.4")
self.requires("harfbuzz/4.2.0")
self.requires("openssl/1.1.1n")

default_options 中我们设置 Qt 编译为动态库,并且启用 qttools,因为其中包括 macdeploy 和 windeploy 等工具。其中要注意的是 generators 配置:

  • 添加 qt 支持主要是为了生成 qt.conf 配置文件,其内容决定了 Qt 依赖库的位置(如 plugins 目录),这在我们调试时非常有用,不需要拷贝这些依赖库到执行程序目录
  • 添加 cmake_find_package_multicmake_paths 主要是为了我们 CMakeLists.txt 中使用 find_package 能查找到指定 Qt 库文件以链接它们
  • 添加 cmake 是为了能通过 CMakeLists.txt 来组织工程,引入头文件路径、库文件路径等信息

另外,由于 Qt 6.2.4 在 macOS 下编译时因为 CMake 和 Qt 依赖的 openssl 版本不一致,我们需要再主工程中覆盖 openssl 1.1.1n 版本。harfbuzz 因为旧版本编译不通过问题,我们覆盖使用 4.2.0 版本。在 Windows 下,我们还可以使用不同版本的 Qt。 接下来添加 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
cmake_minimum_required(VERSION 3.18)

# 设置基础环境
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

# 设置默认的编译配置为 Debug,conan.cmake 需要确定你当前正在使用哪种编译配置以决定如何下载和编译三方库
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
message(STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}")
endif ()

project(QtWithConan VERSION 0.1 LANGUAGES CXX)

# 判断如果当前 CMAKE_BINARY_DIR 目录没有 conanbuildinfo.cmake 的配置信息证明还没有正确加载 Conan 库
# 从 github 下载好 conan.cmake 并 include 到 CMake 工程中
# 判断是否指定了 CONAN_PROFILE_BUILD 和 CONAN_PROFILE_HOST 参数以决定是否使用交叉编译,这里暂时不讨论
# 如果不是交叉编译,则调用 conan_cmake_autodetect 自动监测当前 CMake 环境配置,如 C++ 标准、build-type、编译器等信息
# 调用 conan_cmake_install 根据获取的 settings 和 conanfile.py 配置自动安装依赖包,其中 BUILD mssing 表示如果 conan center 没有我们需要的预编译包,则执行本地编译。
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif ()
include(${CMAKE_BINARY_DIR}/conan.cmake)
if (CONAN_PROFILE_BUILD AND CONAN_PROFILE_HOST)
conan_cmake_install(PATH_OR_REFERENCE .. BUILD missing
SETTINGS_HOST build_type=${CMAKE_BUILD_TYPE}
SETTINGS_BUILD build_type=${CMAKE_BUILD_TYPE}
PROFILE_BUILD ${CONAN_PROFILE_BUILD}
PROFILE_HOST ${CONAN_PROFILE_HOST})
# ENV_HOST CONAN_CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
else ()
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .. BUILD missing SETTINGS ${settings})
endif ()
endif ()

# 在 conan_cmake_install 执行后,会在 CMAKE_BINARY_DIR 目录下生成 cmake 的配置信息和 Qt 的依赖库路径信息,我们将其引入到 CMake 工程中,并调用 conan_basic_setup 来自动配置各个环境变量信息。
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
conan_basic_setup(${PROJECT_NAME} KEEP_RPATHS)

# 查找 Qt 包信息备用
if (MSVC)
find_package(Qt5 COMPONENTS Core Widgets Gui CONFIG REQUIRED)
else ()
find_package(Qt6 COMPONENTS Core Widgets Gui CONFIG REQUIRED)
endif ()

# 开启 MOC
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# 扫描当前源代码文件列表
file(GLOB QT_WITH_CONAN_SOURCES *.cc *.h)

# 创建可执行程序
if (APPLE)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${QT_WITH_CONAN_SOURCES})
else ()
add_executable(${PROJECT_NAME} ${QT_WITH_CONAN_SOURCES})
endif ()

# 链接 Conan 指向的 Qt 库文件
target_link_libraries(${PROJECT_NAME} PRIVATE
${CONAN_LIBS}
)

执行 CMake 初始化:

1
cmake -Bbuild -GXcode -DCMAKE_BUILD_TYPE=Debug

第一次执行如果依赖库没有下载到预编译版本,则会执行本地编译,我这里因为以前执行过,所以直接使用本地缓存的预编译包,执行结果如下:

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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: checking conan executable
-- Conan: Found program /opt/homebrew/bin/conan
-- Conan: Version found Conan version 1.46.2
-- Conan executing: /opt/homebrew/bin/conan install .. --build missing --settings build_type=Debug --settings compiler=apple-clang --settings compiler.version=13.1 --settings compiler.libcxx=libc++ --settings compiler.cppstd=17
Configuration:
[settings]
arch=armv8
arch_build=armv8
build_type=Debug
compiler=apple-clang
compiler.cppstd=17
compiler.libcxx=libc++
compiler.version=13.1
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

WARN: qt/6.2.4: requirement openssl/1.1.1m overridden by QtConanExample/None to openssl/1.1.1n
WARN: qt/6.2.4: requirement harfbuzz/4.0.1 overridden by QtConanExample/None to harfbuzz/4.2.0
brotli/1.0.9: Main binary package '6124f2723e498ba98ee9b85ff813e81aa399a58b' missing. Using compatible package '3558c54d13382045caaf9174821b7c2ba01fc8bc'
bzip2/1.0.8: Main binary package '6a8f360aed14aff13d8ddb3a32e1ac042a72a395' missing. Using compatible package '06955caeb41bcd97dbb7ebe09828eda1babd28fa'
libffi/3.4.2: Main binary package '6124f2723e498ba98ee9b85ff813e81aa399a58b' missing. Using compatible package '3558c54d13382045caaf9174821b7c2ba01fc8bc'
libiconv/1.16: Main binary package '6124f2723e498ba98ee9b85ff813e81aa399a58b' missing. Using compatible package '3558c54d13382045caaf9174821b7c2ba01fc8bc'
libpq/13.6: Main binary package '6124f2723e498ba98ee9b85ff813e81aa399a58b' missing. Using compatible package '3558c54d13382045caaf9174821b7c2ba01fc8bc'
openssl/1.1.1n: Main binary package '6124f2723e498ba98ee9b85ff813e81aa399a58b' missing. Using compatible package '3558c54d13382045caaf9174821b7c2ba01fc8bc'
sqlite3/3.38.0: Main binary package '4b18043335f4b93b24c90599ef9fcdc6cf569224' missing. Using compatible package '87c3a3000b09e726d1a3b9987e9ff7eb84e72a82'
libgettext/0.21: Main binary package '167d7ddb8e26c6af90ba2b5eed8bc3b8ff227a71' missing. Using compatible package 'c8ba9d6f1c61c2b402385fd9257330e2c2f8713f'
odbc/2.3.9: Main binary package 'de44fd0b07324c733424e4662de714428c850f4d' missing. Using compatible package '1f620d3f03ec65f6910dff5f878e64e9102e98bf'
conanfile.py (QtConanExample/None): Installing package
Requirements
brotli/1.0.9 from 'conancenter' - Cache
bzip2/1.0.8 from 'conancenter' - Cache
double-conversion/3.2.0 from 'conancenter' - Cache
freetype/2.11.1 from 'conancenter' - Cache
glib/2.72.0 from 'conancenter' - Cache
harfbuzz/4.2.0 from 'conancenter' - Cache
libelf/0.8.13 from 'conancenter' - Cache
libffi/3.4.2 from 'conancenter' - Cache
libgettext/0.21 from 'conancenter' - Cache
libiconv/1.16 from 'conancenter' - Cache
libpng/1.6.37 from 'conancenter' - Cache
libpq/13.6 from 'conancenter' - Cache
odbc/2.3.9 from 'conancenter' - Cache
opengl/system from 'conancenter' - Cache
openssl/1.1.1n from 'conancenter' - Cache
pcre/8.45 from 'conancenter' - Cache
pcre2/10.37 from 'conancenter' - Cache
qt/6.2.4 from 'conancenter' - Cache
sqlite3/3.38.0 from 'conancenter' - Cache
zlib/1.2.11 from 'conancenter' - Cache
Packages
brotli/1.0.9:3558c54d13382045caaf9174821b7c2ba01fc8bc - Cache
bzip2/1.0.8:06955caeb41bcd97dbb7ebe09828eda1babd28fa - Cache
double-conversion/3.2.0:9ab6b5268e1e31344781b6eb82fd25bc69f64229 - Cache
freetype/2.11.1:1e7e42d6bc8ad96ac1dd79c77c2b80cc77648658 - Cache
glib/2.72.0:8cf2c65ee77e333d132ef82e03743202f400bc80 - Cache
harfbuzz/4.2.0:c5d295637f713bb89c950c5c43d6e342649cfb72 - Cache
libelf/0.8.13:6124f2723e498ba98ee9b85ff813e81aa399a58b - Cache
libffi/3.4.2:3558c54d13382045caaf9174821b7c2ba01fc8bc - Cache
libgettext/0.21:c8ba9d6f1c61c2b402385fd9257330e2c2f8713f - Cache
libiconv/1.16:3558c54d13382045caaf9174821b7c2ba01fc8bc - Cache
libpng/1.6.37:184380d575d622518986cc4403dfa7d731b59655 - Cache
libpq/13.6:3558c54d13382045caaf9174821b7c2ba01fc8bc - Cache
odbc/2.3.9:1f620d3f03ec65f6910dff5f878e64e9102e98bf - Cache
opengl/system:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache
openssl/1.1.1n:3558c54d13382045caaf9174821b7c2ba01fc8bc - Cache
pcre/8.45:e1a9e5802b33a58a01e5aff6e26d47828c02b7cc - Cache
pcre2/10.37:7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78 - Cache
qt/6.2.4:16e3026ebdae7d3adf8365cbf3f000377ba3f77b - Cache
sqlite3/3.38.0:87c3a3000b09e726d1a3b9987e9ff7eb84e72a82 - Cache
zlib/1.2.11:6124f2723e498ba98ee9b85ff813e81aa399a58b - Cache

Installing (downloading, building) binaries...
brotli/1.0.9: Already installed!
bzip2/1.0.8: Already installed!
bzip2/1.0.8: Appending PATH environment variable: /Users/jj.deng/.conan/data/bzip2/1.0.8/_/_/package/06955caeb41bcd97dbb7ebe09828eda1babd28fa/bin
double-conversion/3.2.0: Already installed!
libelf/0.8.13: Already installed!
libffi/3.4.2: Already installed!
libiconv/1.16: Already installed!
libiconv/1.16: Appending PATH environment var: /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/bin
libpq/13.6: Already installed!
opengl/system: Already installed!
openssl/1.1.1n: Already installed!
sqlite3/3.38.0: Already installed!
sqlite3/3.38.0: Appending PATH env var with : /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/bin
zlib/1.2.11: Already installed!
libgettext/0.21: Already installed!
libpng/1.6.37: Already installed!
odbc/2.3.9: Already installed!
odbc/2.3.9: Appending PATH environment variable: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/bin
pcre/8.45: Already installed!
pcre/8.45: Appending PATH environment variable: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/bin
pcre2/10.37: Already installed!
pcre2/10.37: Appending PATH environment variable: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/bin
freetype/2.11.1: Already installed!
glib/2.72.0: Already installed!
glib/2.72.0: Appending PATH env var with: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/bin
harfbuzz/4.2.0: Already installed!
qt/6.2.4: Already installed!
conanfile.py (QtConanExample/None): Generator cmake_paths created conan_paths.cmake
conanfile.py (QtConanExample/None): Generator cmake created conanbuildinfo.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created Qt6ConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created Qt6Target-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created Qt6Targets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created Qt6Config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created OpenSSLConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created OpenSSLTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created OpenSSLTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created OpenSSLConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRE2ConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRE2Target-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRE2Targets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRE2Config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created double-conversion-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created double-conversion-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created double-conversionTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created double-conversionTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created harfbuzz-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created harfbuzz-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created harfbuzzTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created harfbuzzTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created SQLite3ConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created SQLite3Target-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created SQLite3Targets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created SQLite3Config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PostgreSQLConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PostgreSQLTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PostgreSQLTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PostgreSQLConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ODBCConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ODBCTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ODBCTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ODBCConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created opengl_system-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created opengl_system-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created opengl_systemTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created opengl_systemTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created freetype-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created freetype-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created freetypeTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created freetypeTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created glib-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created glibTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created glibTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created glib-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PNGConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PNGConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PNGTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PNGTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BrotliConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BrotliTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BrotliTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BrotliConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libffi-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libffi-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libffiTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libffiTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCREConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRETarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCRETargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created PCREConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libelf-config-version.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libelf-config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libelfTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created libelfTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IntlConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IntlConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IntlTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IntlTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ZLIBConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ZLIBConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ZLIBTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created ZLIBTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BZip2ConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BZip2Config.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BZip2Targets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created BZip2Target-debug.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IconvConfigVersion.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IconvConfig.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IconvTargets.cmake
conanfile.py (QtConanExample/None): Generator cmake_find_package_multi created IconvTarget-debug.cmake
conanfile.py (QtConanExample/None): Generator txt created conanbuildinfo.txt
conanfile.py (QtConanExample/None): Generator qt created qt.conf
conanfile.py (QtConanExample/None): Aggregating env generators
conanfile.py (QtConanExample/None): Generated conaninfo.txt
conanfile.py (QtConanExample/None): Generated graphinfo
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/jj.deng/Documents/temporary/qt-conan-example/build
-- Library Qt6Network_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Network_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Network_debug.dylib
-- Library Qt6Test_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Test_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Test_debug.dylib
-- Library Qt6PrintSupport_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6PrintSupport_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6PrintSupport_debug.dylib
-- Library Qt6OpenGLWidgets_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGLWidgets_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGLWidgets_debug.dylib
-- Library Qt6OpenGL_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGL_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGL_debug.dylib
-- Library Qt6Concurrent_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Concurrent_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Concurrent_debug.dylib
-- Library Qt6UiTools_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6UiTools_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6UiTools_debug.dylib
-- Library Qt6Designer_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Designer_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Designer_debug.dylib
-- Library Qt6Xml_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Xml_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Xml_debug.dylib
-- Library Qt6Help_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Help_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Help_debug.dylib
-- Library Qt6Sql_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Sql_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Sql_debug.dylib
-- Library Qt6Widgets_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Widgets_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Widgets_debug.dylib
-- Library Qt6Gui_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Gui_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Gui_debug.dylib
-- Library Qt6Core_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Core_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Core_debug.dylib
-- Library Qt6Core_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Core_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Core_debug.dylib
-- Library Qt6Gui_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Gui_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Gui_debug.dylib
-- Library Qt6Widgets_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Widgets_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Widgets_debug.dylib
-- Library Qt6Sql_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Sql_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Sql_debug.dylib
-- Library Qt6Help_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Help_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Help_debug.dylib
-- Library Qt6Xml_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Xml_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Xml_debug.dylib
-- Library Qt6Designer_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Designer_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Designer_debug.dylib
-- Library Qt6UiTools_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6UiTools_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6UiTools_debug.dylib
-- Library Qt6Concurrent_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Concurrent_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Concurrent_debug.dylib
-- Library Qt6OpenGL_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGL_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGL_debug.dylib
-- Library Qt6OpenGLWidgets_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGLWidgets_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6OpenGLWidgets_debug.dylib
-- Library Qt6PrintSupport_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6PrintSupport_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6PrintSupport_debug.dylib
-- Library Qt6Test_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Test_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Test_debug.dylib
-- Library Qt6Network_debug found /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Network_debug.dylib
-- Found: /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib/libQt6Network_debug.dylib
-- Conan: Component 'Core' found in package 'Qt6'
-- Conan: Component 'Widgets' found in package 'Qt6'
-- Conan: Component 'Gui' found in package 'Qt6'
-- Library sqlite3 found /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/lib/libsqlite3.a
-- Found: /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/lib/libsqlite3.a
-- Library sqlite3 found /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/lib/libsqlite3.a
-- Found: /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/lib/libsqlite3.a
-- Library pq found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpq.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpq.a
-- Library pgcommon found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon.a
-- Library pgcommon_shlib found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon_shlib.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon_shlib.a
-- Library pgport found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport.a
-- Library pgport_shlib found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport_shlib.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport_shlib.a
-- Library pgport found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport.a
-- Library pgport_shlib found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport_shlib.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgport_shlib.a
-- Library pgcommon found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon.a
-- Library pgcommon_shlib found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon_shlib.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpgcommon_shlib.a
-- Library pq found /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpq.a
-- Found: /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libpq.a
-- Library odbc found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbc.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbc.a
-- Library odbcinst found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbcinst.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbcinst.a
-- Library odbccr found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbccr.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbccr.a
-- Library ltdl found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libltdl.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libltdl.a
-- Library ltdl found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libltdl.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libltdl.a
-- Library odbccr found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbccr.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbccr.a
-- Library odbcinst found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbcinst.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbcinst.a
-- Library odbc found /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbc.a
-- Found: /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib/libodbc.a
-- Library iconv found /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libiconv.a
-- Found: /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libiconv.a
-- Library charset found /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcharset.a
-- Found: /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcharset.a
-- Library ssl found /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libssl.a
-- Found: /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libssl.a
-- Library crypto found /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcrypto.a
-- Found: /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcrypto.a
-- Library crypto found /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcrypto.a
-- Found: /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libcrypto.a
-- Library ssl found /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libssl.a
-- Found: /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libssl.a
-- Library brotlidec-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlidec-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlidec-static.a
-- Library brotlienc-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlienc-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlienc-static.a
-- Library brotlicommon-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlicommon-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlicommon-static.a
-- Library brotlicommon-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlicommon-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlicommon-static.a
-- Library brotlienc-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlienc-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlienc-static.a
-- Library brotlidec-static found /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlidec-static.a
-- Found: /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libbrotlidec-static.a
-- Library freetyped found /Users/jj.deng/.conan/data/freetype/2.11.1/_/_/package/1e7e42d6bc8ad96ac1dd79c77c2b80cc77648658/lib/libfreetyped.a
-- Found: /Users/jj.deng/.conan/data/freetype/2.11.1/_/_/package/1e7e42d6bc8ad96ac1dd79c77c2b80cc77648658/lib/libfreetyped.a
-- Library png16d found /Users/jj.deng/.conan/data/libpng/1.6.37/_/_/package/184380d575d622518986cc4403dfa7d731b59655/lib/libpng16d.a
-- Found: /Users/jj.deng/.conan/data/libpng/1.6.37/_/_/package/184380d575d622518986cc4403dfa7d731b59655/lib/libpng16d.a
-- Library z found /Users/jj.deng/.conan/data/zlib/1.2.11/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib/libz.a
-- Found: /Users/jj.deng/.conan/data/zlib/1.2.11/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib/libz.a
-- Dependency ZLIB already found
-- Library bz2 found /Users/jj.deng/.conan/data/bzip2/1.0.8/_/_/package/06955caeb41bcd97dbb7ebe09828eda1babd28fa/lib/libbz2.a
-- Found: /Users/jj.deng/.conan/data/bzip2/1.0.8/_/_/package/06955caeb41bcd97dbb7ebe09828eda1babd28fa/lib/libbz2.a
-- Dependency Brotli already found
-- Dependency PNG already found
-- Library harfbuzz found /Users/jj.deng/.conan/data/harfbuzz/4.2.0/_/_/package/c5d295637f713bb89c950c5c43d6e342649cfb72/lib/libharfbuzz.a
-- Found: /Users/jj.deng/.conan/data/harfbuzz/4.2.0/_/_/package/c5d295637f713bb89c950c5c43d6e342649cfb72/lib/libharfbuzz.a
-- Dependency freetype already found
-- Library gthread-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgthread-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgthread-2.0.a
-- Library gio-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgio-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgio-2.0.a
-- Library gmodule-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgmodule-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgmodule-2.0.a
-- Library gobject-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgobject-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgobject-2.0.a
-- Library glib-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libglib-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libglib-2.0.a
-- Library glib-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libglib-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libglib-2.0.a
-- Library gobject-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgobject-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgobject-2.0.a
-- Library gmodule-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgmodule-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgmodule-2.0.a
-- Library gio-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgio-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgio-2.0.a
-- Library gthread-2.0 found /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgthread-2.0.a
-- Found: /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib/libgthread-2.0.a
-- Dependency ZLIB already found
-- Library ffi found /Users/jj.deng/.conan/data/libffi/3.4.2/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libffi.a
-- Found: /Users/jj.deng/.conan/data/libffi/3.4.2/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib/libffi.a
-- Library pcreposix found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcreposix.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcreposix.a
-- Library pcre found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre.a
-- Library pcre16 found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre16.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre16.a
-- Library pcre32 found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre32.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre32.a
-- Library pcre32 found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre32.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre32.a
-- Library pcre16 found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre16.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre16.a
-- Library pcre found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcre.a
-- Library pcreposix found /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcreposix.a
-- Found: /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib/libpcreposix.a
-- Dependency BZip2 already found
-- Dependency ZLIB already found
-- Library gnuintl found /Users/jj.deng/.conan/data/libgettext/0.21/_/_/package/c8ba9d6f1c61c2b402385fd9257330e2c2f8713f/lib/libgnuintl.a
-- Found: /Users/jj.deng/.conan/data/libgettext/0.21/_/_/package/c8ba9d6f1c61c2b402385fd9257330e2c2f8713f/lib/libgnuintl.a
-- Dependency Iconv already found
-- Dependency Iconv already found
-- Library elf found /Users/jj.deng/.conan/data/libelf/0.8.13/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib/libelf.a
-- Found: /Users/jj.deng/.conan/data/libelf/0.8.13/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib/libelf.a
-- Dependency ZLIB already found
-- Library pcre2-posix found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-posix.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-posix.a
-- Library pcre2-8 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-8.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-8.a
-- Library pcre2-16 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-16.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-16.a
-- Library pcre2-32 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-32.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-32.a
-- Library pcre2-32 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-32.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-32.a
-- Library pcre2-16 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-16.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-16.a
-- Library pcre2-8 found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-8.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-8.a
-- Library pcre2-posix found /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-posix.a
-- Found: /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib/libpcre2-posix.a
-- Dependency ZLIB already found
-- Dependency BZip2 already found
-- Library double-conversion found /Users/jj.deng/.conan/data/double-conversion/3.2.0/_/_/package/9ab6b5268e1e31344781b6eb82fd25bc69f64229/lib/libdouble-conversion.a
-- Found: /Users/jj.deng/.conan/data/double-conversion/3.2.0/_/_/package/9ab6b5268e1e31344781b6eb82fd25bc69f64229/lib/libdouble-conversion.a
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jj.deng/Documents/temporary/qt-conan-example/build

可以看到,我们的 find_package 等命令成功命中了所有 Qt 依赖库,接下来执行编译:

1
cmake --build build --config Debug

如无故障,可执行程序就生成到 build/bin 目录下了。直接执行即可运行程序:

1
open ./build/bin/QtWithConan.app

一个空白的 Qt 应用就成功运行起来了: 我们查看一下 QtWithConan.app 的目录结构:

1
2
3
4
5
6
7
8
9
10
➜  bin git:(master) ✗ tree
.
└── QtWithConan.app
└── Contents
├── Info.plist
├── MacOS
│ └── QtWithConan
├── PkgInfo
└── _CodeSignature
└── CodeResources

可以看到,这里面并没有 Qt 的依赖库文件,而是只有我们的 app 可执行文件,为什么他可以运行呢?其实执行 conan 包初始化时这些依赖库的路径信息会当做 @rpath 信息自动添加到我们的可执行程序中。使用 otool -l 命令可以查看详情:

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
➜  bin git:(master) ✗ otool -l QtWithConan.app/Contents/MacOS/QtWithConan
QtWithConan.app/Contents/MacOS/QtWithConan:
Load command 44
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/lib (offset 12)
Load command 45
cmd LC_RPATH
cmdsize 136
path /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/res/archdatadir/plugins/platforms (offset 12)
Load command 46
cmd LC_RPATH
cmdsize 136
path /Users/jj.deng/.conan/data/qt/6.2.4/_/_/package/16e3026ebdae7d3adf8365cbf3f000377ba3f77b/res/archdatadir/plugins/sqldrivers (offset 12)
Load command 47
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/openssl/1.1.1n/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib (offset 12)
Load command 48
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/pcre2/10.37/_/_/package/7ea3780a24683d8ea9da9f0de9b3bbcb7b117f78/lib (offset 12)
Load command 49
cmd LC_RPATH
cmdsize 120
path /Users/jj.deng/.conan/data/double-conversion/3.2.0/_/_/package/9ab6b5268e1e31344781b6eb82fd25bc69f64229/lib (offset 12)
Load command 50
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/harfbuzz/4.2.0/_/_/package/c5d295637f713bb89c950c5c43d6e342649cfb72/lib (offset 12)
Load command 51
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/sqlite3/3.38.0/_/_/package/87c3a3000b09e726d1a3b9987e9ff7eb84e72a82/lib (offset 12)
Load command 52
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libpq/13.6/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib (offset 12)
Load command 53
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/odbc/2.3.9/_/_/package/1f620d3f03ec65f6910dff5f878e64e9102e98bf/lib (offset 12)
Load command 54
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/freetype/2.11.1/_/_/package/1e7e42d6bc8ad96ac1dd79c77c2b80cc77648658/lib (offset 12)
Load command 55
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/glib/2.72.0/_/_/package/8cf2c65ee77e333d132ef82e03743202f400bc80/lib (offset 12)
Load command 56
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libpng/1.6.37/_/_/package/184380d575d622518986cc4403dfa7d731b59655/lib (offset 12)
Load command 57
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/brotli/1.0.9/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib (offset 12)
Load command 58
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libffi/3.4.2/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib (offset 12)
Load command 59
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/pcre/8.45/_/_/package/e1a9e5802b33a58a01e5aff6e26d47828c02b7cc/lib (offset 12)
Load command 60
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libelf/0.8.13/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib (offset 12)
Load command 61
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libgettext/0.21/_/_/package/c8ba9d6f1c61c2b402385fd9257330e2c2f8713f/lib (offset 12)
Load command 62
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/zlib/1.2.11/_/_/package/6124f2723e498ba98ee9b85ff813e81aa399a58b/lib (offset 12)
Load command 63
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/bzip2/1.0.8/_/_/package/06955caeb41bcd97dbb7ebe09828eda1babd28fa/lib (offset 12)
Load command 64
cmd LC_RPATH
cmdsize 112
path /Users/jj.deng/.conan/data/libiconv/1.16/_/_/package/3558c54d13382045caaf9174821b7c2ba01fc8bc/lib (offset 12)

可以看到,所有依赖库的路径信息都添加到 LC_RPATH 中了,这就使我们在本地调试应用的时候不需要将 Qt 的依赖库部署到可执行文件目录下了。但 Windows 有点不一样,Windows 不像 macOS 一样可以给执行程序添加 @rpath 信息,这就要求我们再调试的时候也需要部署 Qt 依赖库到可执行程序目录下。并且 macOS 的应用我们如果需要发布给其他人使用,也一样需要将依赖库拷贝到 app bundle 中。接下来我们将介绍如何通过 CMake 执行部署流程。

Deploy Qt 应用

Qt 在不同平台下提供了部署工具,如 macOS 下使用 macdeployqt,Windows 下使用 windeployqt 工具。在我们依赖 Qt 的时候,指定了 qttools 的工具包,这个工具包就包含了这些部署工具。所以我们在 CMake 中直接 find_package 即可找到他们。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if (APPLE)
# macOS 下我们查找 macdeployqt 可执行程序
find_program(DEPLOYQT_EXECUTABLE macdeployqt)
# 设置仅在 Release 发布包编译后执行 deploy 操作。因为调试环境下我们所依赖的库路径都已经在可执行程序的 @rpath 中了。所以没有必要每次都部署
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${DEPLOYQT_EXECUTABLE} ${CMAKE_BINARY_DIR}/bin/QtWithConan.app
COMMENT "Deploying qt dependencies after build..."
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif ()
if (MSVC)
# Windows 下我们查找 windeployqt 可执行程序
find_program(DEPLOYQT_EXECUTABLE windeployqt)
# Windows 同上,但是不能仅在 Release 下才执行,调试环境依然需要部署
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${DEPLOYQT_EXECUTABLE} ${CMAKE_BINARY_DIR}/bin/QtWithConan.exe
COMMENT "Deploying qt dependencies after build..."
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif ()

将以上 CMake 脚本添加到 CMakeLists.txt 最后。然后重新执行 Release 的编译:

1
2
cmake -Bbuild -GXcode -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

执行后再次查看 QtWithConan.app 目录结构:

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
➜  bin git:(master) tree
.
└── QtWithConan.app
└── Contents
├── Frameworks
│ ├── libQt6Concurrent.6.dylib
│ ├── libQt6Core.6.dylib
│ ├── libQt6Designer.6.dylib
│ ├── libQt6Gui.6.dylib
│ ├── libQt6Help.6.dylib
│ ├── libQt6Network.6.dylib
│ ├── libQt6OpenGL.6.dylib
│ ├── libQt6OpenGLWidgets.6.dylib
│ ├── libQt6PrintSupport.6.dylib
│ ├── libQt6Sql.6.dylib
│ ├── libQt6Test.6.dylib
│ ├── libQt6UiTools.6.dylib
│ ├── libQt6Widgets.6.dylib
│ ├── libQt6Xml.6.dylib
│ ├── libdouble-conversion.3.dylib
│ └── libmd4c.0.dylib
├── Info.plist
├── MacOS
│ └── QtWithConan
└── Resources
└── qt.conf

5 directories, 19 files

在 deploy 后,该应用就已经可以拷贝给其他人使用了。对于 macOS 下最低支持版本、签名等问题 CMake 均有处理方案,这里不过多做赘述,如果有需要的同学可以参考项目:https://github.com/nmgwddj/qt6-conan-cmake-sample

总结

Qt 的应用部署以前我们都是高度依赖 qmake 或其他第三方脚本,并且不同平台下处理会有各种各样的问题,通过 Conan + CMake 的方案,我们完全可以实现在不同平台下两条命令就可以编译出产物的需求。如:

1
2
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

你可以通过 CI 的打包工具将 .app 文件和 .exe 文件夹打包成压缩包或者制作成 dmg 进行分发。如果有更换 Qt 版本需求,我们仅需要再 conanfile.py 中修改一下 Qt 版本就可以自动执行所有编译流程了,永远告别 qmake 和繁琐的编译脚本。