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>
(cherry picked from commit dab8f64b6d5d4241b678d0227355858071376496)
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2021-05-31 13:52:19 +02:00
parent ca661cdead
commit d7ce6346ee

View File

@ -728,6 +728,7 @@ macro(qt_examples_build_begin)
endif()
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)
@ -819,7 +820,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()