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
Fixes: QTBUG-127857
Change-Id: Ie80edb98ce16b6835fe361198953e36b8255102a
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 34f127834c2d83517687522b5725f6a67f67bad2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-08-09 15:04:41 +02:00 committed by Qt Cherry-pick Bot
parent c7a9c813fe
commit fe200fb713

View File

@ -564,14 +564,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()
@ -585,8 +588,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().
@ -597,6 +602,7 @@ macro(qt_build_repo_impl_examples)
add_subdirectory(examples)
endif()
unset(__qt_repo_project_name_lowercase)
endif()
endmacro()