From 44c9ad561799b51c1e4d10c8b9821fbff6143ef1 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 7 Jun 2019 18:13:53 +0200 Subject: [PATCH] Improve pro2cmake.py more Fix incorrect usage of CMAKE_CURRENT_BUILD_DIR, there is no such CMake variable, it's actually CMAKE_CURRENT_BINARY_DIR. Also if the host_build option is set when building a module, the library should be a static library. Change-Id: I9fb39905118dbd7f33d9821960eaed11f20b30c6 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann --- util/cmake/pro2cmake.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 0de5fce5591..94c79656386 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -601,9 +601,9 @@ class Scope(object): return ['${CMAKE_CURRENT_SOURCE_DIR}/' + os.path.relpath(self.currentdir, self.basedir),] if key == 'OUT_PWD': if is_same_path: - return ['${CMAKE_CURRENT_BUILD_DIR}'] + return ['${CMAKE_CURRENT_BINARY_DIR}'] else: - return ['${CMAKE_CURRENT_BUILD_DIR}/' + os.path.relpath(self.currentdir, self.basedir),] + return ['${CMAKE_CURRENT_BINARY_DIR}/' + os.path.relpath(self.currentdir, self.basedir),] return self._evalOps(key, None, [], inherrit=inherrit) @@ -1603,7 +1603,12 @@ def write_module(cm_fh: typing.IO[str], scope: Scope, *, print('XXXXXX Module name {} does not start with Qt!'.format(module_name)) extra = [] - if 'static' in scope.get('CONFIG'): + + # A module should be static when 'static' is in CONFIG + # or when option(host_build) is used, as described in qt_module.prf. + is_static = 'static' in scope.get('CONFIG') or 'host_build' in scope.get('_OPTION') + + if is_static: extra.append('STATIC') if 'internal_module' in scope.get('CONFIG'): extra.append('INTERNAL_MODULE')