diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-03 17:08:50 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-06 19:00:34 +0000 |
commit | 3a6d5f2b946215866136ab20403a4f53a74af6fe (patch) | |
tree | c2a137f7675e5422179ee7a7d937d6a7b9092959 | |
parent | 00f29b77c0e996f03a8ff7967ca33ea5f0499d65 (diff) |
CMake: Allow opting out of building examples as ExternalProjects
We default to configuring examples as separate ExternalProjects when
using a developer / non-prefix Qt build.
This ensures we test that the examples configure successfully without
the pollution of the main Qt build (e.g. already found packages).
One down-side of this is that a developer's IDE doesn't see these
example targets, unless each project is loaded into the IDE
separately. This is cumbersome to do when refactoring or renaming
code across multiple example projects.
Allow configuring the example projects as part of the main Qt build
by setting QT_BUILD_EXAMPLES_AS_EXTERNAL to FALSE when configuring Qt.
Save the value of the variable in QtBuildInternalsExtra.cmake.in
so it's propagated to leaf repositories as well.
Amends dab8f64b6d5d4241b678d0227355858071376496
Amends d97fd7af2bc5c89a0ad9e5fac080041b78d01179
Task-number: QTBUG-90820
Task-number: QTBUG-94608
Task-number: QTBUG-96232
Task-number: QTCREATORBUG-26168
Change-Id: Ie1f724f74365b3a788b04c3fffe9eb2d0611dd50
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit c8dbb177f03bcd8e65b8fac1008fe276fada2c92)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 4 | ||||
-rw-r--r-- | cmake/QtBuildInternalsExtra.cmake.in | 3 | ||||
-rw-r--r-- | cmake/QtSetup.cmake | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index f77f1bb8b0..89c13afe01 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -669,8 +669,8 @@ macro(qt_examples_build_begin) cmake_parse_arguments(arg "${options}" "${singleOpts}" "${multiOpts}" ${ARGN}) - # FIXME: Support prefix builds as well - if(arg_EXTERNAL_BUILD AND NOT QT_WILL_INSTALL) + # FIXME: Support prefix builds as well QTBUG-96232 + if(arg_EXTERNAL_BUILD AND QT_BUILD_EXAMPLES_AS_EXTERNAL) # Examples will be built using ExternalProject. # We always depend on all plugins so as to prevent opportunities for # weird errors associated with loading out-of-date plugins from diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 91161b00c8..6c76c17093 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -69,6 +69,9 @@ set(QT_BUILD_EXAMPLES_BY_DEFAULT @QT_BUILD_EXAMPLES_BY_DEFAULT@ CACHE BOOL set(QT_BUILD_TOOLS_BY_DEFAULT @QT_BUILD_TOOLS_BY_DEFAULT@ CACHE BOOL "Should tools be built as part of the default 'all' target.") +set(QT_BUILD_EXAMPLES_AS_EXTERNAL "@QT_BUILD_EXAMPLES_AS_EXTERNAL@" CACHE BOOL + "Should examples be built as ExternalProjects.") + # Propagate usage of ccache. set(QT_USE_CCACHE @QT_USE_CCACHE@ CACHE BOOL "Enable the use of ccache") diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 17357dc1a4..7de8dfc8de 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -174,6 +174,17 @@ enable_testing() option(QT_BUILD_EXAMPLES "Build Qt examples" OFF) option(QT_BUILD_EXAMPLES_BY_DEFAULT "Should examples be built as part of the default 'all' target." ON) + +# FIXME: Support prefix builds as well QTBUG-96232 +if(QT_WILL_INSTALL) + set(_qt_build_examples_as_external OFF) +else() + set(_qt_build_examples_as_external ON) +endif() +option(QT_BUILD_EXAMPLES_AS_EXTERNAL "Should examples be built as ExternalProjects." + ${_qt_build_examples_as_external}) +unset(_qt_build_examples_as_external) + option(QT_BUILD_MANUAL_TESTS "Build Qt manual tests" OFF) option(QT_BUILD_MINIMAL_STATIC_TESTS "Build minimal subset of tests for static Qt builds" OFF) |