diff --git a/local/recipes/qt/qtshadertools/recipe.toml b/local/recipes/qt/qtshadertools/recipe.toml index 5cfa93e88b..7cfcfe26d4 100644 --- a/local/recipes/qt/qtshadertools/recipe.toml +++ b/local/recipes/qt/qtshadertools/recipe.toml @@ -72,6 +72,287 @@ if [ ! -f "${HOST_BUILD}/libexec/qsb" ] || [ ! -f "${HOST_QST_STAMP}" ]; then printf '%s\n' "6.11.1" > "${HOST_QST_STAMP}" fi +# ============================================================ +# Step 1b: Generate Qt6ShaderToolsTools cmake package +# The host build installs qsb but doesn't generate the cross-compile +# tools wrapper package. Qt's cmake framework expects +# find_package(Qt6ShaderToolsTools) to provide Qt6::qsb. +# We generate the minimal cmake files following the same pattern +# as Qt6WaylandScannerTools (from qtbase host build). +# ============================================================ +QSB_TOOLS_DIR="${HOST_BUILD}/lib/cmake/Qt6ShaderToolsTools" +if [ ! -f "${QSB_TOOLS_DIR}/Qt6ShaderToolsToolsConfig.cmake" ]; then + mkdir -p "${QSB_TOOLS_DIR}" + python3 - <<'PYGEN' +import os +from pathlib import Path + +host = Path(os.environ["HOST_BUILD"]) +qsb_path = host / "bin" / "qsb" +tools_dir = host / "lib" / "cmake" / "Qt6ShaderToolsTools" +tools_dir.mkdir(parents=True, exist_ok=True) + +pkg_name = "ShaderToolsTools" +ns = "Qt6" +target = "qsb" + +# Config.cmake +(tools_dir / f"{ns}{pkg_name}Config.cmake").write_text(f"""\ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +get_filename_component(PACKAGE_PREFIX_DIR "${{CMAKE_CURRENT_LIST_DIR}}/../../../" ABSOLUTE) + +macro(set_and_check _var _file) + set(${{_var}} "${{_file}}") + if(NOT EXISTS "${{_file}}") + message(FATAL_ERROR "File or directory ${{_file}} referenced by variable ${{_var}} does not exist !") + endif() +endmacro() + +macro(check_required_components _NAME) + foreach(comp ${{{_NAME}_FIND_COMPONENTS}}) + if(NOT ${{_NAME}}_${{comp}}_FOUND) + if(${{_NAME}}_FIND_REQUIRED_${{comp}}) + set(${{_NAME}}_FOUND FALSE) + endif() + endif() + endforeach() +endmacro() + +cmake_minimum_required(VERSION 3.16...3.21) +include(CMakeFindDependencyMacro) + +if(EXISTS "${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}Dependencies.cmake") + include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}Dependencies.cmake") +endif() + +if(NOT DEFINED "{ns}{pkg_name}_FOUND") + set("{ns}{pkg_name}_FOUND" TRUE) +endif() + +set(__qt_{pkg_name}_should_include_targets_code "TRUE") + +if(__qt_{pkg_name}_should_include_targets_code) + include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}TargetsPrecheck.cmake") +endif() + +if(NOT __qt_{pkg_name}_skip_include_targets_file + AND {ns}{pkg_name}_FOUND + AND __qt_{pkg_name}_should_include_targets_code + ) + include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}Targets.cmake") + include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}AdditionalTargetInfo.cmake") + if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS) + include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}VersionlessTargets.cmake") + endif() + set(__qt_{pkg_name}_targets_file_included ON) +endif() + +if(__qt_{pkg_name}_targets_file_included AND {ns}{pkg_name}_FOUND) + __qt_internal_promote_target_to_global({ns}::{target}) +endif() +set({ns}{pkg_name}_TARGETS "{ns}::{target}") +""") + +# Targets.cmake +(tools_dir / f"{ns}{pkg_name}Targets.cmake").write_text(f"""\ +# Generated by Red Bear OS qtshadertools recipe + +if("${{CMAKE_MAJOR_VERSION}}.${{CMAKE_MINOR_VERSION}}" LESS 2.8) + message(FATAL_ERROR "CMake >= 2.8.3 required") +endif() +if(CMAKE_VERSION VERSION_LESS "2.8.3") + message(FATAL_ERROR "CMake >= 2.8.3 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.8.3...4.1) + +set(CMAKE_IMPORT_FILE_VERSION 1) + +set(_cmake_targets_defined "") +set(_cmake_targets_not_defined "") +set(_cmake_expected_targets "") +foreach(_cmake_expected_target IN ITEMS {ns}::{target}) + list(APPEND _cmake_expected_targets "${{_cmake_expected_target}}") + if(TARGET "${{_cmake_expected_target}}") + list(APPEND _cmake_targets_defined "${{_cmake_expected_target}}") + else() + list(APPEND _cmake_targets_not_defined "${{_cmake_expected_target}}") + endif() +endforeach() +unset(_cmake_expected_target) +if(_cmake_targets_defined STREQUAL _cmake_expected_targets) + unset(_cmake_targets_defined) + unset(_cmake_targets_not_defined) + unset(_cmake_expected_targets) + unset(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT _cmake_targets_defined STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.") +endif() +unset(_cmake_targets_defined) +unset(_cmake_targets_not_defined) +unset(_cmake_expected_targets) + +get_filename_component(_IMPORT_PREFIX "${{CMAKE_CURRENT_LIST_FILE}}" PATH) +get_filename_component(_IMPORT_PREFIX "${{_IMPORT_PREFIX}}" PATH) +get_filename_component(_IMPORT_PREFIX "${{_IMPORT_PREFIX}}" PATH) +get_filename_component(_IMPORT_PREFIX "${{_IMPORT_PREFIX}}" PATH) +if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") +endif() + +# Create imported target {ns}::{target} +add_executable({ns}::{target} IMPORTED) + +set_target_properties({ns}::{target} PROPERTIES + COMPATIBLE_INTERFACE_STRING "QT_MAJOR_VERSION" + INTERFACE_QT_MAJOR_VERSION "6" +) + +# Load information for each installed configuration. +file(GLOB _cmake_config_files "${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}Targets-*.cmake") +foreach(_cmake_config_file IN LISTS _cmake_config_files) + include("${{_cmake_config_file}}") +endforeach() +unset(_cmake_config_file) +unset(_cmake_config_files) + +set(_IMPORT_PREFIX) +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) +""") + +# Targets-release.cmake +rel = tools_dir / f"{ns}{pkg_name}Targets-release.cmake" +rel.write_text(f"""\ +# Generated by Red Bear OS qtshadertools recipe + +# Import target "{ns}::{target}" for configuration "Release" +set_property(TARGET {ns}::{target} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties({ns}::{target} PROPERTIES + IMPORTED_LOCATION_RELEASE "{qsb_path}" +) + +set(_cmake_import_check_targets "{ns}::{target}") +set(_cmake_import_check_files_for_{ns}::{target} "{qsb_path}") +""") + +# Precheck +(tools_dir / f"{ns}{pkg_name}TargetsPrecheck.cmake").write_text(f"""\ +_qt_internal_should_include_targets( + TARGETS {target} + NAMESPACE {ns}:: + OUT_VAR_SHOULD_SKIP __qt_{pkg_name}_skip_include_targets_file +) +""") + +# AdditionalTargetInfo +(tools_dir / f"{ns}{pkg_name}AdditionalTargetInfo.cmake").write_text(f"""\ +# Additional target information for {ns}{pkg_name} +if(NOT DEFINED QT_DEFAULT_IMPORT_CONFIGURATION) + set(QT_DEFAULT_IMPORT_CONFIGURATION RELEASE) +endif() +get_target_property(_qt_imported_location {ns}::{target} IMPORTED_LOCATION_RELEASE) +get_target_property(_qt_imported_location_default {ns}::{target} IMPORTED_LOCATION_${{QT_DEFAULT_IMPORT_CONFIGURATION}}) + +set_property(TARGET {ns}::{target} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) +if(_qt_imported_location) + set_property(TARGET {ns}::{target} PROPERTY IMPORTED_LOCATION_RELWITHDEBINFO "${{_qt_imported_location}}") +endif() + +set_property(TARGET {ns}::{target} APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL) +if(_qt_imported_location) + set_property(TARGET {ns}::{target} PROPERTY IMPORTED_LOCATION_MINSIZEREL "${{_qt_imported_location}}") +endif() + +if(_qt_imported_location_default) + set_property(TARGET {ns}::{target} PROPERTY IMPORTED_LOCATION "${{_qt_imported_location_default}}") +endif() + +unset(_qt_imported_location) +unset(_qt_imported_location_default) +""") + +# VersionlessTargets +(tools_dir / f"{ns}{pkg_name}VersionlessTargets.cmake").write_text(f"""\ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +foreach(__qt_tool {target}) + if(NOT TARGET Qt::${{__qt_tool}} AND TARGET {ns}::${{__qt_tool}}) + add_executable(Qt::${{__qt_tool}} IMPORTED GLOBAL) + foreach(__qt_imported_location_config + IMPORTED_LOCATION + IMPORTED_LOCATION_RELEASE + IMPORTED_LOCATION_RELWITHDEBINFO + IMPORTED_LOCATION_MINSIZEREL + IMPORTED_LOCATION_DEBUG) + get_target_property(__qt_imported_location + {ns}::${{__qt_tool}} ${{__qt_imported_location_config}}) + if(__qt_imported_location AND EXISTS "${{__qt_imported_location}}") + break() + endif() + endforeach() + set_target_properties(Qt::${{__qt_tool}} + PROPERTIES IMPORTED_LOCATION "${{__qt_imported_location}}") + endif() +endforeach() +""") + +# Dependencies +(tools_dir / f"{ns}{pkg_name}Dependencies.cmake").write_text(f"""\ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause +set({ns}{pkg_name}_FOUND TRUE) +""") + +# ConfigVersionImpl +(tools_dir / f"{ns}{pkg_name}ConfigVersionImpl.cmake").write_text(f"""\ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +set(PACKAGE_VERSION "6.11.1") + +if(PACKAGE_FIND_VERSION_EXACT) + if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() +else() + if(PACKAGE_FIND_VERSION VERSION_LESS_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() +endif() + +if(NOT PACKAGE_VERSION_COMPATIBLE) + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() +""") + +# ConfigVersion +(tools_dir / f"{ns}{pkg_name}ConfigVersion.cmake").write_text(f"""\ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause +include("${{CMAKE_CURRENT_LIST_DIR}}/{ns}{pkg_name}ConfigVersionImpl.cmake") +set(__qt_disable_package_version_check FALSE) +if(__qt_disable_package_version_check) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + unset(PACKAGE_VERSION_UNSUITABLE) +endif() +unset(__qt_disable_package_version_check) +""") + +print(f"Generated Qt6ShaderToolsTools cmake package at {tools_dir}") +PYGEN +fi + # ============================================================ # Step 2: Cross-compile qtshadertools for Redox # ============================================================