From dece6f17e613b757530eb3d78c79dfaffb94f270 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 25 Feb 2022 13:04:35 +0100 Subject: [PATCH] pro2cmake: Set a project version for examples For example projects, change the generated project() call to project(foo VERSION 1.0 LANGUAGES CXX) Some CMake API derives default values from the project version, and it's generally advisable to set a project version number. The version number is read from qmake's VERSION variable. That's actually a target version number, but it might be the right thing in most cases. Fall back to version 1.0 if VERSION is not set. Task-number: QTBUG-96799 Change-Id: Ia0c551cf62621eb217e1dd541dcbd8945f78138e Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index ada3d97b2e6..0361a992807 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -3795,9 +3795,10 @@ def write_example( "$$[QT_INSTALL_EXAMPLES]", "${INSTALL_EXAMPLESDIR}" ) + project_version = scope.get_string("VERSION", "1.0") cm_fh.write( f"cmake_minimum_required(VERSION {cmake_version_string})\n" - f"project({binary_name} LANGUAGES CXX)\n\n" + f"project({binary_name} VERSION {project_version} LANGUAGES CXX)\n\n" "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n" "set(CMAKE_AUTOMOC ON)\n" "set(CMAKE_AUTOUIC ON)\n\n"