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>
16 lines
743 B
CMake
16 lines
743 B
CMake
# 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()
|