summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-07 12:15:10 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-07 23:22:33 +0200
commit5c9ab44ff6e3c2cda7738cfba5ab32f4be174ef2 (patch)
treed805266ee8c6cf4ccff254f6296eaf58a0ccab23
parent8365322d3de709e86fc6c3962472dcc8944fb0a3 (diff)
CMake: Simplify semicolon escaping in qt_config_compile_test
list(JOIN) removes a layer of escaping, which force doubling up on the backslashes. Instead use string(REPLACE) thus making the escaping a bit saner. Change-Id: Ie3daf0112dd09fbcbaf8798552949470952611c9 Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtFeature.cmake19
1 files changed, 7 insertions, 12 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index 9e88ceac91..b2d993647f 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -657,7 +657,6 @@ function(qt_config_compile_test name)
endif()
# Pass which packages need to be found.
- # Very scary / ugly escaping incoming.
if(arg_PACKAGES)
set(packages_list "")
@@ -667,9 +666,8 @@ function(qt_config_compile_test name)
foreach(p ${arg_PACKAGES})
if(p STREQUAL PACKAGE)
if(package_entry)
- # Use 6 backslashes + ; which will be collapsed when doing variable
- # expansion at multiple stages.
- list(JOIN package_entry "\\\\\\;" package_entry_string)
+ # Encode the ";" into "\;" to separate the arguments of a find_package call.
+ string(REPLACE ";" "\\;" package_entry_string "${package_entry}")
list(APPEND packages_list "${package_entry_string}")
endif()
@@ -680,18 +678,15 @@ function(qt_config_compile_test name)
endforeach()
# Parse final entry.
if(package_entry)
- list(JOIN package_entry "\\\\\\;" package_entry_string)
+ string(REPLACE ";" "\\;" package_entry_string "${package_entry}")
list(APPEND packages_list "${package_entry_string}")
endif()
- # Before the join, packages_list has 3 backslashes + ; for each package part
- # (name, component) if you display them.
- # After the join, packages_list has 2 backslashes + ; for each package part, and a
- # '\;' to separate package entries.
- list(JOIN packages_list "\;" packages_list)
+ # Encode the ";" again.
+ string(REPLACE ";" "\\;" packages_list "${packages_list}")
- # Finally when appending the joined string to the flags, the flags are separated by
- # ';', the package entries by '\;', and the packages parts of an entry by '\\;'.
+ # The flags are separated by ';', the find_package entries by '\;',
+ # and the package parts of an entry by '\\;'.
# Example:
# WrapFoo\\;6\\;COMPONENTS\\;bar\;WrapBaz\\;5
list(APPEND flags "-DQT_CONFIG_COMPILE_TEST_PACKAGES:STRING=${packages_list}")