summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2023-07-25 15:41:03 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2024-03-11 13:47:53 +0100
commit43d0c5ed6ef666b4ef9f33c018240f551fb6ebae (patch)
tree186373378b948694174b018785bbc91b782027b4 /cmake
parente65dc193327c207d71e20fa14a5dbf1a988afd60 (diff)
CMake: Allow passing extra variables to external project examples
In some repos we need to be able to pass extra cache variables to find 3rd party packages when building examples as external projects. Introduce QT_EXAMPLE_CMAKE_VARS_TO_PASS to allow passing vars like OpenSSL_ROOT or Protobuf_ROOT if they are set in the repo project. It should be noted that QT_EXAMPLE_CMAKE_VARS_TO_PASS expects a special syntax for its values, of the from VAR_NAME:CMAKE_TYPE, due to the pre-existing implementation on how we pass variables to ExternalProject. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: Ie3e74d4fde106f947d12e51d27e41a310157aab6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildRepoExamplesHelpers.cmake10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmake/QtBuildRepoExamplesHelpers.cmake b/cmake/QtBuildRepoExamplesHelpers.cmake
index b9186a0044..91fa29ae5c 100644
--- a/cmake/QtBuildRepoExamplesHelpers.cmake
+++ b/cmake/QtBuildRepoExamplesHelpers.cmake
@@ -382,7 +382,15 @@ function(qt_internal_add_example_external_project subdir)
CMAKE_OBJCXX_COMPILER_LAUNCHER:STRING
)
- foreach(var_with_type IN LISTS vars_to_pass_if_defined)
+ # QT_EXAMPLE_CMAKE_VARS_TO_PASS can be set by specific repos to pass any additional required
+ # CMake cache variables.
+ # One use case is passing locations of 3rd party package locations like Protobuf via _ROOT
+ # variables.
+ set(extra_vars_var_name "")
+ if(QT_EXAMPLE_CMAKE_VARS_TO_PASS)
+ set(extra_vars_var_name "QT_EXAMPLE_CMAKE_VARS_TO_PASS")
+ endif()
+ foreach(var_with_type IN LISTS vars_to_pass_if_defined ${extra_vars_var_name})
string(REPLACE ":" ";" key_as_list "${var_with_type}")
list(GET key_as_list 0 var)
if(NOT DEFINED ${var})