使用 Conan、CMake 組織跨平臺 Qt 工程

語言: CN / TW / HK

建立 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

#include <QtWidgets/QWidget>

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

main_form.cc

#include "main_form.h"

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

MainForm::~MainForm() {}

main.cc

#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

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

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 初始化:

cmake -Bbuild -GXcode -DCMAKE_BUILD_TYPE=Debug

第一次執行如果依賴庫沒有下載到預編譯版本,則會執行本地編譯,我這裡因為以前執行過,所以直接使用本地快取的預編譯包,執行結果如下:

-- 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 依賴庫,接下來執行編譯:

cmake --build build --config Debug

如無故障,可執行程式就生成到 build/bin 目錄下了。直接執行即可執行程式:

open ./build/bin/QtWithConan.app

一個空白的 Qt 應用就成功執行起來了:

我們檢視一下 QtWithConan.app 的目錄結構:

➜  bin git:(master) ✗ tree
.
└── QtWithConan.app
    └── Contents
        ├── Info.plist
        ├── MacOS
        │   └── QtWithConan
        ├── PkgInfo
        └── _CodeSignature
            └── CodeResources

可以看到,這裡面並沒有 Qt 的依賴庫檔案,而是隻有我們的 app 可執行檔案,為什麼他可以執行呢?其實執行 conan 包初始化時這些依賴庫的路徑資訊會當做 @rpath 資訊自動新增到我們的可執行程式中。使用 otool -l 命令可以檢視詳情:

➜  bin git:(master) ✗ otool -l QtWithConan.app/Contents/MacOS/QtWithConan
QtWithConan.app/Contents/MacOS/QtWithConan:
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __PAGEZERO
   vmaddr 0x0000000000000000
   vmsize 0x0000000100000000
  fileoff 0
 filesize 0
  maxprot 0x00000000
 initprot 0x00000000
   nsects 0
    flags 0x0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 472
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x000000000000c000
  fileoff 0
 filesize 49152
  maxprot 0x00000005
 initprot 0x00000005
   nsects 5
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x000000010000b9b8
      size 0x0000000000000494
    offset 47544
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x000000010000be4c
      size 0x00000000000000b4
    offset 48716
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 12 (size of stubs)
Section
  sectname __const
   segname __TEXT
      addr 0x000000010000bf00
      size 0x0000000000000065
    offset 48896
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __gcc_except_tab
   segname __TEXT
      addr 0x000000010000bf68
      size 0x0000000000000018
    offset 49000
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x000000010000bf80
      size 0x0000000000000080
    offset 49024
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 232
  segname __DATA_CONST
   vmaddr 0x000000010000c000
   vmsize 0x0000000000004000
  fileoff 49152
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 2
    flags 0x10
Section
  sectname __got
   segname __DATA_CONST
      addr 0x000000010000c000
      size 0x0000000000000080
    offset 49152
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 15 (index into indirect symbol table)
 reserved2 0
Section
  sectname __const
   segname __DATA_CONST
      addr 0x000000010000c080
      size 0x0000000000000258
    offset 49280
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 152
  segname __DATA
   vmaddr 0x0000000100010000
   vmsize 0x0000000000004000
  fileoff 65536
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 1
    flags 0x0
Section
  sectname __data
   segname __DATA
      addr 0x0000000100010000
      size 0x0000000000000070
    offset 65536
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 4
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000100014000
   vmsize 0x000000000000c000
  fileoff 81920
 filesize 33392
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 5
      cmd LC_DYLD_CHAINED_FIXUPS
  cmdsize 16
  dataoff 81920
 datasize 3720
Load command 6
      cmd LC_DYLD_EXPORTS_TRIE
  cmdsize 16
  dataoff 85640
 datasize 1056
Load command 7
     cmd LC_SYMTAB
 cmdsize 24
  symoff 86720
   nsyms 197
  stroff 90000
 strsize 5784
Load command 8
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 104
     iextdefsym 104
     nextdefsym 24
      iundefsym 128
      nundefsym 69
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 89872
  nindirectsyms 31
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 9
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 10
     cmd LC_UUID
 cmdsize 24
    uuid FA2AF0AD-66DE-3708-AF16-A3DFC31E76EE
Load command 11
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 12.3
      sdk 12.3
   ntools 1
     tool 3
  version 762.0
Load command 12
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 13
       cmd LC_MAIN
   cmdsize 24
  entryoff 48092
 stacksize 0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6Network_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Test_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6PrintSupport_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 17
          cmd LC_LOAD_DYLIB
      cmdsize 72
         name @rpath/libQt6OpenGLWidgets_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 18
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6OpenGL_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 19
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6Concurrent_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 20
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6UiTools_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 21
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6Designer_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 22
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Xml_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 23
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Help_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 24
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Sql_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 25
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name @rpath/libQt6Widgets_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 26
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Gui_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 27
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libQt6Core_debug.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 6.2.4
compatibility version 6.0.0
Load command 28
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1300.23.0
compatibility version 1.0.0
Load command 29
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libresolv.9.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 30
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 165.0.0
compatibility version 2.0.0
Load command 31
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.5.0
compatibility version 1.2.0
Load command 32
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 275.0.0
compatibility version 1.0.0
Load command 33
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 34
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Metal.framework/Versions/A/Metal (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 261.13.0
compatibility version 1.0.0
Load command 35
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.11.0
compatibility version 1.2.0
Load command 36
          cmd LC_LOAD_DYLIB
      cmdsize 104
         name /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1557.5.4
compatibility version 64.0.0
Load command 37
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 38
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 39
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 2113.40.126
compatibility version 45.0.0
Load command 40
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1858.112.0
compatibility version 300.0.0
Load command 41
          cmd LC_LOAD_DYLIB
      cmdsize 104
         name /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1141.1.0
compatibility version 1.0.0
Load command 42
          cmd LC_LOAD_DYLIB
      cmdsize 104
         name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1858.112.0
compatibility version 150.0.0
Load command 43
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1311.100.3
compatibility version 1.0.0
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)
Load command 65
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 86696
 datasize 24
Load command 66
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 86720
 datasize 0
Load command 67
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 95792
 datasize 19520

可以看到,所有依賴庫的路徑資訊都新增到 LC_RPATH 中了,這就使我們在本地除錯應用的時候不需要將 Qt 的依賴庫部署到可執行檔案目錄下了。但 Windows 有點不一樣,Windows 不像 macOS 一樣可以給執行程式新增 @rpath 資訊,這就要求我們再除錯的時候也需要部署 Qt 依賴庫到可執行程式目錄下。並且 macOS 的應用我們如果需要釋出給其他人使用,也一樣需要將依賴庫拷貝到 app bundle 中。接下來我們將介紹如何通過 CMake 執行部署流程。

Deploy Qt 應用

Qt 在不同平臺下提供了部署工具,如 macOS 下使用 macdeployqt,Windows 下使用 windeployqt 工具。在我們依賴 Qt 的時候,指定了 qttools 的工具包,這個工具包就包含了這些部署工具。所以我們在 CMake 中直接 find_package 即可找到他們。

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 的編譯:

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

執行後再次檢視 QtWithConan.app 目錄結構:

➜  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 的方案,我們完全可以實現在不同平臺下兩條命令就可以編譯出產物的需求。如:

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

你可以通過 CI 的打包工具將 .app 檔案和 .exe 資料夾打包成壓縮包或者製作成 dmg 進行分發。如果有更換 Qt 版本需求,我們僅需要再 conanfile.py 中修改一下 Qt 版本就可以自動執行所有編譯流程了,永遠告別 qmake 和繁瑣的編譯指令碼。