summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 11:41:17 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 17:48:57 +0100
commit3680d3453c5f0ae45c71ee0afa75edbf894dfe7f (patch)
tree8327847e1fb85f877fb2a71c7aa2f093933dd830 /util/cmake/pro2cmake.py
parent36e56263d5534849edc73abe44169e4d4d31ed28 (diff)
CMake: pro2cmake: Generate correct CONFIG_MODULE_NAME values
The CONFIG_MODULE_NAME option to qt_internal_add_module is used to specify what the name of a Qt module's pri file should, as well as some of the key names assigned in that file, as well as what should be passed to QT += in qmake projects. When it is not specified, the computed value is the lower case of the CMake target name. E.g. for qt_internal_add_module(Core), the computed CONFIG_MODULE_NAME is 'core'. The qmake variable that determines the above value is the MODULE variable. If it is not explicitly assigned, it's computed from the .pro file name, rather than from the TARGET variable value. Thus there is an inconsistency in how the value is auto-computed in CMake compared to qmake. We had a few special cases in projects that assign a correct CONFIG_MODULE_NAME when the auto-computed value was wrong. Teach pro2cmake to detect these inconsistencies and pass a correct CONFIG_MODULE_NAME value based on the .pro file name. This way we get rid of the special cases as well. Aka if there is no explicit MODULE assignment in the .pro file, and the auto-computed value by CMake is different from the one computed by qmake, explicitly write out a CONFIG_MODULE_NAME value with what qmake would have computed. Task-number: QTBUG-88025 Change-Id: I166b29767e87cd6b0c681fa53238098355a177f9 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 9ba0e95765..a2ee168035 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -3325,9 +3325,10 @@ def forward_target_info(scope: Scope, extra: List[str], skip: Optional[Dict[str,
def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
- module_name = scope.TARGET
- if not module_name.startswith("Qt"):
- print(f"XXXXXX Module name {module_name} does not start with Qt!")
+ # e.g. QtCore
+ qt_module_name = scope.TARGET
+ if not qt_module_name.startswith("Qt"):
+ print(f"XXXXXX Module name {qt_module_name} does not start with Qt!")
extra = []
@@ -3337,6 +3338,24 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
is_public_module = True
+ # CMake target name as passed to qt_internal_add_module()
+ # e.g. Core
+ cmake_target_name = qt_module_name[2:]
+
+ # MODULE is used for the name of the generated .pri file.
+ # If MODULE is not explicitly set, qmake computes its value in
+ # mkspecs/features/qt_build_config.prf
+ module_name_for_pri = scope.expandString("MODULE")
+ if not module_name_for_pri:
+ module_name_for_pri_as_qmake_computes_it = scope.file[:-4]
+ module_name_for_pri = module_name_for_pri_as_qmake_computes_it
+
+ # Given 'qt_internal_add_module(Core)', computes 'core'.
+ module_name_for_pri_as_cmake_computes_it = cmake_target_name.lower()
+
+ if module_name_for_pri != module_name_for_pri_as_cmake_computes_it:
+ extra.append(f'CONFIG_MODULE_NAME {module_name_for_pri}')
+
if is_static:
extra.append("STATIC")
if "internal_module" in scope.get("CONFIG"):
@@ -3365,11 +3384,10 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
scope._is_public_module = is_public_module
- target_name = module_name[2:]
forward_target_info(scope, extra)
write_main_part(
cm_fh,
- target_name,
+ cmake_target_name,
"Module",
f"{get_cmake_api_call('qt_add_module')}",
scope,
@@ -3383,10 +3401,10 @@ def write_module(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> str:
tracepoints = scope.get_files("TRACEPOINT_PROVIDER")
create_trace_points = get_cmake_api_call("qt_create_tracepoints")
cm_fh.write(
- f"\n\n{spaces(indent)}{create_trace_points}({module_name[2:]} {' '.join(tracepoints)})\n"
+ f"\n\n{spaces(indent)}{create_trace_points}({cmake_target_name} {' '.join(tracepoints)})\n"
)
- return target_name
+ return cmake_target_name
def write_tool(cm_fh: IO[str], scope: Scope, *, indent: int = 0) -> Tuple[str, str]: