diff --git a/cmake/QtPublicSbomHelpers.cmake b/cmake/QtPublicSbomHelpers.cmake index 49056a6c015..ce674273dde 100644 --- a/cmake/QtPublicSbomHelpers.cmake +++ b/cmake/QtPublicSbomHelpers.cmake @@ -216,7 +216,29 @@ function(_qt_internal_sbom_begin_project) _qt_internal_get_current_project_sbom_dir(sbom_dir) set_property(GLOBAL APPEND PROPERTY _qt_internal_sbom_dirs "${sbom_dir}") - file(GLOB license_files "${PROJECT_SOURCE_DIR}/LICENSES/LicenseRef-*.txt") + # Collect project licenses. + set(license_dirs "") + + if(EXISTS "${PROJECT_SOURCE_DIR}/LICENSES") + list(APPEND license_dirs "${PROJECT_SOURCE_DIR}/LICENSES") + endif() + + # Allow specifying extra license dirs via a variable. Useful for standalone projects + # like sqldrivers. + if(QT_SBOM_LICENSE_DIRS) + foreach(license_dir IN LISTS QT_SBOM_LICENSE_DIRS) + if(EXISTS "${license_dir}") + list(APPEND license_dirs "${license_dir}") + endif() + endforeach() + endif() + list(REMOVE_DUPLICATES license_dirs) + + set(license_file_wildcard "LicenseRef-*.txt") + list(TRANSFORM license_dirs APPEND "/${license_file_wildcard}" OUTPUT_VARIABLE license_globs) + + file(GLOB license_files ${license_globs}) + foreach(license_file IN LISTS license_files) get_filename_component(license_id "${license_file}" NAME_WLE) _qt_internal_sbom_add_license( diff --git a/src/plugins/sqldrivers/CMakeLists.txt b/src/plugins/sqldrivers/CMakeLists.txt index 65f7fd47662..48369909961 100644 --- a/src/plugins/sqldrivers/CMakeLists.txt +++ b/src/plugins/sqldrivers/CMakeLists.txt @@ -22,8 +22,10 @@ if(NOT PROJECT_NAME STREQUAL "QtBase" AND NOT PROJECT_NAME STREQUAL "Qt") BuildInternals Core Sql - ) - qt_prepare_standalone_project() + ) + # Use qtbase license files for standalone builds. + set(QT_SBOM_LICENSE_DIRS "${PROJECT_SOURCE_DIR}/../../../LICENSES") + qt_build_repo_begin() else() qt_internal_upgrade_cmake_policies() endif() @@ -77,5 +79,5 @@ if(QT_FEATURE_sql_mimer) endif() if(NOT CMAKE_PROJECT_NAME STREQUAL "QtBase" AND NOT CMAKE_PROJECT_NAME STREQUAL "Qt") - qt_print_feature_summary() + qt_build_repo_end() endif()