From 34f127834c2d83517687522b5725f6a67f67bad2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 9 Aug 2024 15:04:41 +0200 Subject: [PATCH] CMake: Use lowercase project name for skipping tests and examples Previously one had to specify names like 'QtSvg' to -skip-tests and -skip-examples, but this is not the same behavior as what the -submodules and -skip options expect. To keep it consistent, change the code to consider only the lower case names. Amends 25b89f2c88cdfc98bfa462949531a33f7ef50996 Amends 7c9efdf40c9d9f7f89f7a9be0c06e0d3ec54ec2c Pick-to: 6.7 6.8 Fixes: QTBUG-127857 Change-Id: Ie80edb98ce16b6835fe361198953e36b8255102a Reviewed-by: Alexey Edelev Reviewed-by: Joerg Bornemann --- cmake/QtBuildRepoHelpers.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake index fdb26d3a2ca..c8357cd6e85 100644 --- a/cmake/QtBuildRepoHelpers.cmake +++ b/cmake/QtBuildRepoHelpers.cmake @@ -582,14 +582,17 @@ macro(qt_build_repo_impl_tests) message(FATAL_ERROR "Can't build both standalone tests and standalone examples at once.") endif() - option(QT_BUILD_TESTS_PROJECT_${PROJECT_NAME} "Configure tests for project ${PROJECT_NAME}" TRUE) + string(TOLOWER "${PROJECT_NAME}" __qt_repo_project_name_lowercase) + option(QT_BUILD_TESTS_PROJECT_${__qt_repo_project_name_lowercase} + "Configure tests for project ${__qt_repo_project_name_lowercase}" TRUE) - if (QT_BUILD_TESTS_PROJECT_${PROJECT_NAME}) + if (QT_BUILD_TESTS_PROJECT_${__qt_repo_project_name_lowercase}) add_subdirectory(tests) if(NOT QT_BUILD_TESTS_BY_DEFAULT) set_property(DIRECTORY tests PROPERTY EXCLUDE_FROM_ALL TRUE) endif() endif() + unset(__qt_repo_project_name_lowercase) endif() endmacro() @@ -603,8 +606,10 @@ macro(qt_build_repo_impl_examples) message(STATUS "Configuring examples.") - option(QT_BUILD_EXAMPLES_PROJECT_${PROJECT_NAME} "Configure examples for project ${PROJECT_NAME}" TRUE) - if(QT_BUILD_EXAMPLES_PROJECT_${PROJECT_NAME}) + string(TOLOWER "${PROJECT_NAME}" __qt_repo_project_name_lowercase) + option(QT_BUILD_EXAMPLES_PROJECT_${__qt_repo_project_name_lowercase} + "Configure examples for project ${__qt_repo_project_name_lowercase}" TRUE) + if(QT_BUILD_EXAMPLES_PROJECT_${__qt_repo_project_name_lowercase}) # Set this before any examples subdirectories are added, to warn about examples that are # added via add_subdirectory() calls instead of qt_internal_add_example(). @@ -615,6 +620,7 @@ macro(qt_build_repo_impl_examples) add_subdirectory(examples) endif() + unset(__qt_repo_project_name_lowercase) endif() endmacro()