From f03c7e4a2d65361e79c8271d1278c06aeb63ebea Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Thu, 22 Jun 2023 17:38:39 +0200 Subject: [PATCH] Introduce -no-vcpkg flag for disabling vcpkg detection/integration Vcpkg detection is enabled by default, but we did not have a flag to disable it, and it was not showing up in config.summary either. By adding a -vcpkg flag, we get to use `-no-vcpkg` when necessary, as well as adding an entry to config summary indicating whether vcpkg is in use or not. Besides `-no-vcpkg`, one can pass `-DQT_USE_VCPKG=OFF` to cmake command in order to disable the automatic vcpkg detection/integration. [ChangeLog][configure] vcpkg detection, and integration can be disabled by passing the -no-vcpkg flag to the configure command, or by passing `-DQT_USE_VCPKG=OFF` to the cmake command. Change-Id: Ide8da70a7b473ec23995104d162356e75e6d1240 Reviewed-by: Alexandru Croitor (cherry picked from commit b3f27f75b638c6eb8494d681cd4df50dd34bcac0) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtAutoDetect.cmake | 5 ++++- cmake/QtBuildInternalsExtra.cmake.in | 3 +++ cmake/QtProcessConfigureArgs.cmake | 1 + cmake/configure-cmake-mapping.md | 1 + config_help.txt | 2 ++ configure.cmake | 8 ++++++++ qt_cmdline.cmake | 1 + 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index a994fc5e55f..9a80c96cac5 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -8,6 +8,9 @@ # Make sure to not run detection when building standalone tests, because the detection was already # done when initially configuring qtbase. +# This needs to be here because QtAutoDetect loads before any other modules +option(QT_USE_VCPKG "Enable the use of vcpkg" ON) + function(qt_internal_ensure_static_qt_config) if(NOT DEFINED BUILD_SHARED_LIBS) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Qt statically or dynamically" FORCE) @@ -161,7 +164,7 @@ function(qt_auto_detect_android) endfunction() function(qt_auto_detect_vcpkg) - if(DEFINED ENV{VCPKG_ROOT}) + if(QT_USE_VCPKG AND DEFINED ENV{VCPKG_ROOT}) set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE) diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 2dc906b6c61..2917c2290fd 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -103,6 +103,9 @@ set(QT_BUILD_EXAMPLES_AS_EXTERNAL "@QT_BUILD_EXAMPLES_AS_EXTERNAL@" CACHE BOOL # Propagate usage of ccache. set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache") +# Propagate usage of vcpkg, ON by default. +set(QT_USE_VCPKG @QT_USE_VCPKG@ CACHE BOOL "Enable the use of vcpkg") + # Propagate usage of unity build. set(QT_UNITY_BUILD @QT_UNITY_BUILD@ CACHE BOOL "Enable unity (jumbo) build") set(QT_UNITY_BUILD_BATCH_SIZE "@QT_UNITY_BUILD_BATCH_SIZE@" CACHE STRING "Unity build batch size") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 8dd72ca5ea7..c8f2fecdaf5 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -831,6 +831,7 @@ drop_input(commercial) drop_input(confirm-license) translate_boolean_input(precompile_header BUILD_WITH_PCH) translate_boolean_input(ccache QT_USE_CCACHE) +translate_boolean_input(vcpkg QT_USE_VCPKG) translate_boolean_input(shared BUILD_SHARED_LIBS) translate_boolean_input(warnings_are_errors WARNINGS_ARE_ERRORS) translate_string_input(qt_namespace QT_NAMESPACE) diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 27743cc4e8c..20571481707 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -77,6 +77,7 @@ The following table describes the mapping of configure options to CMake argument | -unity-build-batch-size | -DQT_UNITY_BUILD_BATCH_SIZE= | | | -warnings-are-errors | -DWARNINGS_ARE_ERRORS=ON | | | -no-pkg-config | -DFEATURE_pkg_config=OFF | | +| -no-vcpkg | -DQT_USE_VCPKG=OFF | | | -D | -DQT_EXTRA_DEFINES=; | | | -I | -DQT_EXTRA_INCLUDEPATHS=; | | | -L | -DQT_EXTRA_LIBDIRS=; | | diff --git a/config_help.txt b/config_help.txt index f35ec4cc24c..0ca66c1eef9 100644 --- a/config_help.txt +++ b/config_help.txt @@ -159,6 +159,8 @@ Build environment: -pkg-config .......... Use pkg-config [auto] (Unix only) + -vcpkg ............... Use vcpkg [yes] + -D .......... Pass additional preprocessor define -I .......... Pass additional include path -L .......... Pass additional library path diff --git a/configure.cmake b/configure.cmake index 69c70c9a535..3b5382785aa 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1153,6 +1153,14 @@ qt_configure_add_summary_entry(ARGS "xml") qt_configure_end_summary_section() # end of "Qt modules and options" section qt_configure_add_summary_section(NAME "Support enabled for") qt_configure_add_summary_entry(ARGS "pkg-config") + +if(QT_USE_VCPKG AND (DEFINED ENV{VCPKG_ROOT} OR VCPKG_TARGET_TRIPLET)) + set(_vcpkg_entry_message "yes") +else() + set(_vcpkg_entry_message "no") +endif() +qt_configure_add_summary_entry(ARGS "Using vcpkg" TYPE "message" MESSAGE "${_vcpkg_entry_message}") + qt_configure_add_summary_entry(ARGS "libudev") qt_configure_add_summary_entry(ARGS "openssl") qt_configure_add_summary_entry(ARGS "openssl-linked") diff --git a/qt_cmdline.cmake b/qt_cmdline.cmake index be6ead7ce61..bfd7b8e4323 100644 --- a/qt_cmdline.cmake +++ b/qt_cmdline.cmake @@ -44,6 +44,7 @@ qt_commandline_option(avx2 TYPE boolean) qt_commandline_option(avx512 TYPE boolean NAME avx512f) qt_commandline_option(c++std TYPE cxxstd) qt_commandline_option(ccache TYPE boolean NAME ccache) +qt_commandline_option(vcpkg TYPE boolean) qt_commandline_option(commercial TYPE void) qt_commandline_option(confirm-license TYPE void) qt_commandline_option(dbus TYPE optionalString VALUES no yes linked runtime)