summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-09-06 17:03:41 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-08 15:25:20 +0000
commit33bf269bbee70559e211c96990c6f9752f158b20 (patch)
tree958d3ed6e229e20f5dda823355d3d10fdc13d371 /util
parent4f2ccd7f8397487f3e5c98a64186985f1484d10d (diff)
pro2cmake.py: generate examples with properties in qt_add_executable()
This patch will slightly change the output of CMakeLists.txt files that are generated for examples. * set_target_properties() will no longer be added to the top-level scope. If the WIN32 and MACOSX_BUNDLE properties should be added, they will instead be added to qt_add_executable(). * The version in cmake_minimum_required() will now be 3.16, rather than 3.14. Change-Id: I79e1865dace5538d2b7ff264da02f9e28a655ae9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 8337493301ae25e5afaa94777c0ee0d1e6503660) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 56efa48180..fff3f4708c 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -3686,13 +3686,19 @@ def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
return target
-def write_win32_and_mac_bundle_properties(
- cm_fh: IO[str], scope: Scope, target: str, *, handling_first_scope=False, indent: int = 0
-):
+def get_win32_and_mac_bundle_properties(scope: Scope) -> tuple:
config = scope.get("CONFIG")
win32 = all(val not in config for val in ["cmdline", "console"])
mac_bundle = all(val not in config for val in ["cmdline", "-app_bundle"])
+ return win32, mac_bundle
+
+
+def write_win32_and_mac_bundle_properties(
+ cm_fh: IO[str], scope: Scope, target: str, *, handling_first_scope=False, indent: int = 0
+):
+ win32, mac_bundle = get_win32_and_mac_bundle_properties(scope)
+
true_value = "TRUE"
false_value = "FALSE"
@@ -3710,7 +3716,7 @@ def write_win32_and_mac_bundle_properties(
# without creating excess noise of setting the properties in every
# single scope.
for name, value in properties_mapping.items():
- if handling_first_scope or (not handling_first_scope and value != true_value):
+ if not handling_first_scope and value != true_value:
properties.extend([name, value])
if properties:
@@ -3731,7 +3737,7 @@ def write_example(
)
cm_fh.write(
- "cmake_minimum_required(VERSION 3.14)\n"
+ f"cmake_minimum_required(VERSION {cmake_version_string})\n"
f"project({binary_name} LANGUAGES CXX)\n\n"
"set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"
"set(CMAKE_AUTOMOC ON)\n"
@@ -3856,6 +3862,13 @@ def write_example(
else:
add_target = f"qt_add_executable({binary_name}"
+ property_win32, property_mac_bundle = get_win32_and_mac_bundle_properties(scope)
+
+ if property_win32:
+ add_target += ' ' + "WIN32"
+ if property_mac_bundle:
+ add_target += ' ' + "MACOSX_BUNDLE"
+
write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
cm_fh.write(")\n")