Add QT_CONFIGURE_RUNNING variable for configure.cmake files

configure.cmake files are read twice when using the configure script /
qt-configure-module: First, when configure is running and a second time,
when CMake creates the local build system files.

In the first run, not every function and esp. no targets are
available. Code in configure.cmake that accesses targets or calls
functions unknown to configure will fail at the configure stage.

This patch introduces the QT_CONFIGURE_RUNNING variable that can be used
in configure.cmake files to guard such code:

if(QT_CONFIGURE_RUNNING)
    set(_qt_coord_type double)
else()
    get_property(_qt_coord_type TARGET Qt6::Core
        PROPERTY INTERFACE_QT_COORD_TYPE)
endif()

Change-Id: Iff39924d6a5133379d28c8204d7b7afdf47de5c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 37452051d6b68f20a52c65cffd3cde5cb323156e)
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-01-08 16:36:36 +01:00 committed by Kai Koehne
parent 40c0f00ac0
commit 234cabe51b

View File

@ -186,6 +186,10 @@ function(qt_commandline_assignment var internal_var)
set(commandline_nr_of_assignments ${n} PARENT_SCOPE)
endfunction()
# Check the following variable in configure.cmake files to guard code that is not covered by the
# stub functions above.
set(QT_CONFIGURE_RUNNING ON)
####################################################################################################
# Load qt_cmdline.cmake files