From fab07ca3ef277e64ccb646700f4da2f7dd3a14ce Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 20 Jun 2019 13:23:19 +0200 Subject: [PATCH] Add support for vcpkg default target triplets As per vcpkg documentation, this is a tweak that allows respecting the vcpkg default target triplet environment variable, which simplifies the command line slightly. In order to make this also work for modules other than qtbase, we're going to need to consider the creation of a toolchain file. Change-Id: I2573f6644d671c710fd823df83e2205dbbfe19e6 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- CMakeLists.txt | 4 ++++ cmake/README.md | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3deeaeb7ad4..d47bc91cbfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.15.0) +if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") +endif() + project(QtBase VERSION 6.0.0 DESCRIPTION "Qt Base Libraries" diff --git a/cmake/README.md b/cmake/README.md index 2580fd97fd8..868b4f2d338 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -28,7 +28,7 @@ You may use vcpkg to install dependencies needed to build QtBase. * Run ```bootstrap-vcpkg.bat``` or ```bootstrap-vcpkg.sh``` * Set the ``VCPKG_DEFAULT_TRIPLET`` environment variable to ``qt-x64-windows-static`` or ``qt-x86-windows-static`` * Build Qt dependencies: ``vcpkg install zlib pcre2 harfbuzz freetype openssl zstd`` - * When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET%`` + * When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake`` Previously CMAKE_PREFIX_PATH was mentioned instead of CMAKE_TOOLCHAIN_FILE. Setting CMAKE_PREFIX_PATH to the vcpkg installed folder is not enough, because then find_package is not overridden by vcpkg and cmake might not propagate all library dependencies for static packages (freetype is one such package). # Building against homebrew on macOS @@ -142,7 +142,7 @@ Vcpkg for Android can be set up using the following steps: * Set the ``ANDROID_SDK_HOME`` environment variable to the path where you have installed the Android SDK. * Build Qt dependencies: ``vcpkg install zlib pcre2 harfbuzz freetype openssl zstd`` -When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DVCPKG_TARGET_TRIPLET=$VCPKG_DEFAULT_TRIPLET -DQT_HOST_PATH=/path/to/your/host/build -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_SDK_ROOT=$ANDROID_SDK_HOME -DANDROID_STL=c++_shared -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH`` +When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DQT_HOST_PATH=/path/to/your/host/build -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_SDK_ROOT=$ANDROID_SDK_HOME -DANDROID_STL=c++_shared -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH`` # Debugging CMake files