summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-02-04 19:01:19 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-09 18:08:38 +0000
commiteed719a7ae75014284e51955049762752b8786b3 (patch)
tree9de734452a39b2726ab945841ccd7ee2380941b5 /cmake
parent149ca89ed505ca9ede82a5d079148d1796e432f5 (diff)
CMake: Handle slashes in qt_internal_add_example
qtdeclarative has a call like qt_internal_add_example(imagine/automotive) This causes issues when trying to pass that as the name of the external project. Use the last part after the last slash as the name of the project. Change-Id: Ifc074e50e537f07f3636699ed255d2561930d873 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 92dff7c5f80fbc1e628a278ec4c2b216d24e04bb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index e37a018bb1..952dc3d3ee 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -922,6 +922,19 @@ function(qt_internal_add_example_external_project subdir)
if(NOT arg_NAME)
set(arg_NAME "${subdir}")
+
+ # qtdeclarative has calls like qt_internal_add_example(imagine/automotive)
+ # so passing a nested subdirectory. Custom targets (and thus ExternalProjects) can't contain
+ # slashes, so extract the last part of the path to be used as a name.
+ if(arg_NAME MATCHES "/")
+ string(REPLACE "/" ";" exploded_path "${arg_NAME}")
+ list(POP_BACK exploded_path last_dir)
+ if(NOT last_dir)
+ message(FATAL_ERROR "Example subdirectory must have a name.")
+ else()
+ set(arg_NAME "${last_dir}")
+ endif()
+ endif()
endif()
# Likely a clash with an example subdir ExternalProject custom target of the same name.