summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuildInternals
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-02-04 19:01:19 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-02-09 16:48:25 +0100
commit92dff7c5f80fbc1e628a278ec4c2b216d24e04bb (patch)
treeb857f52b3922e6fb186c2895cc6769e5b9a6d95f /cmake/QtBuildInternals
parent2536d73adc9ee83443165892d391b36c1992c081 (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. Pick-to: 6.2 6.3 Change-Id: Ifc074e50e537f07f3636699ed255d2561930d873 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals')
-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.