summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorChristophe Giboudeaux <christophe@krop.fr>2020-02-06 11:32:48 +0100
committerChristophe Giboudeaux <christophe@krop.fr>2020-05-07 15:41:26 +0200
commit5dcaa11cc26fabc4f4f1336681ac19217a9e0e91 (patch)
treec09c67748b42fecf0018c120a14730659edb6bfa /util/cmake/pro2cmake.py
parentbf315c5526cb5cce6581de89f2747d7d2c3bad0a (diff)
pro2cmake: Honor INSTALL_EXAMPLESDIR if defined
When building examples standalone, 'INSTALL_EXAMPLESDIR' may be undefined. The converted .pro files now check whether the variable is set to prevent installation into unexpected locations. Fixes: QTBUG-81797 Change-Id: I9f97568923c8103011a41d9af7cfe02dd1e40b56 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 48bb8b7d88..f62d24a15c 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -3287,8 +3287,8 @@ def write_example(
example_install_dir = scope.expandString("target.path")
if not example_install_dir:
- example_install_dir = "examples"
- example_install_dir = example_install_dir.replace("$$[QT_INSTALL_EXAMPLES]", "examples")
+ example_install_dir = "${INSTALL_EXAMPLESDIR}"
+ example_install_dir = example_install_dir.replace("$$[QT_INSTALL_EXAMPLES]", "${INSTALL_EXAMPLESDIR}")
cm_fh.write(
"cmake_minimum_required(VERSION 3.14)\n"
@@ -3297,6 +3297,9 @@ def write_example(
"set(CMAKE_AUTOMOC ON)\n"
"set(CMAKE_AUTORCC ON)\n"
"set(CMAKE_AUTOUIC ON)\n\n"
+ "if(NOT DEFINED INSTALL_EXAMPLESDIR)\n"
+ " set(INSTALL_EXAMPLESDIR \"examples\")\n"
+ "endif()\n\n"
f'set(INSTALL_EXAMPLEDIR "{example_install_dir}")\n\n'
)