diff options
| author | Alexandru Croitor <alexandru.croitor@qt.io> | 2025-06-05 13:06:55 +0200 |
|---|---|---|
| committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2025-06-06 16:27:54 +0200 |
| commit | 9b9a2398f30b6c35ef6be3ce929c352afb682910 (patch) | |
| tree | 4140b5235764ac5778ce432b3c8234895c429113 /cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake | |
| parent | 587649deb7188d6944c31d991d0fd2a71f17ab4e (diff) | |
CMake: Make QT_CMAKE_EXPORT_NAMESPACE available in the top-level scope
Previously QT_CMAKE_EXPORT_NAMESPACE was set by calling
find_package(QtBuildInternals) at repo dir scope, even in a top-level
build.
Starting with ddcafa0a51c65d86f6b5481f06fce5faeb75920d in
qtdeclarative, we now have a deferred call of
_qt_internal_write_deferred_qmlls_build_ini_file in the
CMAKE_BINARY_DIR scope, which lacks the QT_CMAKE_EXPORT_NAMESPACE
variable.
This caused errors in a top-level standalone tests build:
Error evaluating generator expression $
No target "::qtpaths"
CMakeLists.txt:DEFERRED
To avoid the error we now set QT_CMAKE_EXPORT_NAMESPACE in the
top level scope.
To avoid duplicating the code into the QtBaseTopLevelHelpers,
we extract the qt_internal_top_level_setup_cmake_and_export_namespace
function into a new QtBuildInternalsHelpers.cmake file, which is
included by both QtBaseTopLevelHelpers.cmake and
QtBuildInternalsConfig.cmake.
We also copy and install that file.
This has less side effects than trying to call
find_package(QtBuildInternals) in the top-level scope.
Pick-to: 6.10
Change-Id: I8e54e21d3f07ee86860cad49d6e43e0fdefbcee3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake')
| -rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake b/cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake new file mode 100644 index 00000000000..aa845fd5c36 --- /dev/null +++ b/cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake @@ -0,0 +1,15 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +macro(qt_internal_setup_cmake_and_export_namespace) + # The variables might have already been set in QtBuildInternalsExtra.cmake if the file is + # included while building a new module and not QtBase. In that case, stop overriding the value. + if(NOT INSTALL_CMAKE_NAMESPACE) + set(INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}" + CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]") + endif() + if(NOT QT_CMAKE_EXPORT_NAMESPACE) + set(QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}" + CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]") + endif() +endmacro() |
