From 6ffe9b1c42267eaf0fc81d16931e1a6f9f39879d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 28 Apr 2020 17:46:21 +0200 Subject: [PATCH] pro2cmake.py: Generate .cmake.conf files for versioning And create one for QtBase at the same time. Fixes: QTBUG-83835 Change-Id: Icc6b022165a57bd4e22c23bdb0016522b99a5b80 Reviewed-by: Alexandru Croitor --- .cmake.conf | 1 + CMakeLists.txt | 3 ++- util/cmake/pro2cmake.py | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .cmake.conf diff --git a/.cmake.conf b/.cmake.conf new file mode 100644 index 00000000000..9305480451b --- /dev/null +++ b/.cmake.conf @@ -0,0 +1 @@ +set(QT_REPO_MODULE_VERSION "6.0.0") diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cf6e7cac35..97fbfac4211 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,9 @@ if (CMAKE_CROSSCOMPILING AND CMAKE_SYSROOT) set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT}) endif() +include(".cmake.conf") project(QtBase - VERSION 6.0.0 + VERSION "${QT_REPO_MODULE_VERSION}" DESCRIPTION "Qt Base Libraries" HOMEPAGE_URL "https://qt.io/" LANGUAGES CXX C ASM diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 89d84124482..48bb8b7d884 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -3846,8 +3846,9 @@ def handle_top_level_repo_project(scope: Scope, cm_fh: IO[str]): f"""\ cmake_minimum_required(VERSION {cmake_version_string}) + include(.cmake.conf) project({qt_lib} - VERSION 6.0.0 + VERSION "${{QT_REPO_MODULE_VERSION}}" DESCRIPTION "Qt {qt_lib_no_prefix} Libraries" HOMEPAGE_URL "https://qt.io/" LANGUAGES CXX C @@ -3868,6 +3869,15 @@ def handle_top_level_repo_project(scope: Scope, cm_fh: IO[str]): cm_fh.write(f"{header}{expand_project_requirements(scope)}{build_repo}") +def create_top_level_cmake_conf(): + conf_file_name = ".cmake.conf" + try: + with open(conf_file_name, 'x') as file: + file.write("set(QT_REPO_MODULE_VERSION \"6.0.0\")\n") + except FileExistsError as _: + pass + + def find_top_level_repo_project_file(project_file_path: str = "") -> Optional[str]: qmake_conf_path = find_qmake_conf(project_file_path) qmake_dir = os.path.dirname(qmake_conf_path) @@ -4034,6 +4044,7 @@ def cmakeify_scope( # Handle top level repo project in a special way. if is_top_level_repo_project(scope.file_absolute_path): + create_top_level_cmake_conf() handle_top_level_repo_project(scope, temp_buffer) # Same for top-level tests. elif is_top_level_repo_tests_project(scope.file_absolute_path):