diff options
author | Joerg Bornemann <[email protected]> | 2022-02-25 13:04:35 +0100 |
---|---|---|
committer | Joerg Bornemann <[email protected]> | 2022-02-28 15:41:18 +0100 |
commit | dece6f17e613b757530eb3d78c79dfaffb94f270 (patch) | |
tree | 7c2db19c7c41613ff50cf307ddc3b9af35cb4185 /util/cmake/pro2cmake.py | |
parent | 2389aaf8c754c78464f27cf480e22a41a89de1b0 (diff) |
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 <[email protected]>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-x | util/cmake/pro2cmake.py | 3 |
1 files changed, 2 insertions, 1 deletions
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" |