From 92dff7c5f80fbc1e628a278ec4c2b216d24e04bb Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 4 Feb 2022 19:01:19 +0100 Subject: 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 Reviewed-by: Alexey Edelev --- cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cmake/QtBuildInternals') 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. -- cgit v1.2.3