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. Pick-to: 6.2 Change-Id: I79e1865dace5538d2b7ff264da02f9e28a655ae9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
28e194d3b2
commit
8337493301
@ -3686,13 +3686,19 @@ def write_jar(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
|
|||||||
return target
|
return target
|
||||||
|
|
||||||
|
|
||||||
def write_win32_and_mac_bundle_properties(
|
def get_win32_and_mac_bundle_properties(scope: Scope) -> tuple:
|
||||||
cm_fh: IO[str], scope: Scope, target: str, *, handling_first_scope=False, indent: int = 0
|
|
||||||
):
|
|
||||||
config = scope.get("CONFIG")
|
config = scope.get("CONFIG")
|
||||||
win32 = all(val not in config for val in ["cmdline", "console"])
|
win32 = all(val not in config for val in ["cmdline", "console"])
|
||||||
mac_bundle = all(val not in config for val in ["cmdline", "-app_bundle"])
|
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"
|
true_value = "TRUE"
|
||||||
false_value = "FALSE"
|
false_value = "FALSE"
|
||||||
|
|
||||||
@ -3710,7 +3716,7 @@ def write_win32_and_mac_bundle_properties(
|
|||||||
# without creating excess noise of setting the properties in every
|
# without creating excess noise of setting the properties in every
|
||||||
# single scope.
|
# single scope.
|
||||||
for name, value in properties_mapping.items():
|
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])
|
properties.extend([name, value])
|
||||||
|
|
||||||
if properties:
|
if properties:
|
||||||
@ -3731,7 +3737,7 @@ def write_example(
|
|||||||
)
|
)
|
||||||
|
|
||||||
cm_fh.write(
|
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"
|
f"project({binary_name} LANGUAGES CXX)\n\n"
|
||||||
"set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"
|
"set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"
|
||||||
"set(CMAKE_AUTOMOC ON)\n"
|
"set(CMAKE_AUTOMOC ON)\n"
|
||||||
@ -3856,6 +3862,13 @@ def write_example(
|
|||||||
else:
|
else:
|
||||||
add_target = f"qt_add_executable({binary_name}"
|
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)
|
write_all_source_file_lists(cm_fh, scope, add_target, indent=0)
|
||||||
cm_fh.write(")\n")
|
cm_fh.write(")\n")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user