CMake: Be precise about EXTERNAL_BUILD check when building examples

This change allows temporarily removing the EXTERNAL_BUILD option in
a qt repo examples project to check how the examples behave in a
non-external project build, without forcing the developer to use a
prefix build.

Useful to compare behavior until we've ported over prefix builds to
use EXTERNAL_BUILD.

Amends d97fd7af2bc5c89a0ad9e5fac080041b78d01179

Change-Id: I29b834bb5f00e1e93966caae6f816faedba76b76
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2021-05-31 13:52:19 +02:00
parent 0f9695e6da
commit dab8f64b6d

View File

@ -678,6 +678,7 @@ macro(qt_examples_build_begin)
# but that should rarely be necessary.
set(QT_EXAMPLE_DEPENDENCIES qt_plugins ${qt_repo_targets_name} ${arg_DEPENDS})
set(QT_EXAMPLE_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(QT_IS_EXTERNAL_EXAMPLES_BUILD TRUE)
string(TOLOWER ${PROJECT_NAME} project_name_lower)
if(NOT TARGET examples)
@ -769,7 +770,8 @@ endmacro()
function(qt_internal_add_example subdir)
# FIXME: Support building examples externally for prefix builds as well.
if(QT_WILL_INSTALL)
if(NOT QT_IS_EXTERNAL_EXAMPLES_BUILD)
# Use old non-external approach
add_subdirectory(${subdir} ${ARGN})
return()