From 27f299d9b5ab770b89928f6b06b3fd5c6a7b609c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 12 Mar 2021 11:57:24 +0100 Subject: [PATCH] CMake Wizards: Advertise manual finalisation In qmake projects it is possible to run arbitrary qmake commands after the whole project is parsed, which is used extensively by Qt to do things like importing qml plugins, generating android deployment files, etc. In CMake this feature was implemented in 3.19+ and we leverage this feature to do all the things described above when such a version is used. But when projects are built with earlier CMake versions, it's better for users to do these steps manually, rather than letting them to happen at qt_add_executable call time, which limits certain configurability. That can be achieved by adding a call to qt_finalize_executable at the very end of the directory scope where the target was created, in addition to adding the MANUAL_FINALIZATION option to the qt_add_executable call. Augment the wizard templates to advertise the existence of qt_finalize_executable, as well as making sure that projects created by Creator can work reasonably well with older CMake versions as well. Change-Id: Icf60eae993cf815f6cce6ed659fe35264b016f62 Reviewed-by: Joerg Bornemann Reviewed-by: Eike Ziller --- .../wizards/projects/qtquickapplication/CMakeLists.txt | 2 ++ .../wizards/projects/qtwidgetsapplication/CMakeLists.txt | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt index 067ecb4f0a8..ab941e27a65 100644 --- a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt @@ -44,6 +44,7 @@ set(PROJECT_SOURCES if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(%{ProjectName} + MANUAL_FINALIZATION ${PROJECT_SOURCES} ) @if %{HasTranslation} @@ -79,4 +80,5 @@ set_target_properties(%{ProjectName} PROPERTIES if(QT_VERSION_MAJOR EQUAL 6) qt_import_qml_plugins(%{ProjectName}) + qt_finalize_executable(%{ProjectName}) endif() diff --git a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt index 8edfe2de599..c4e7f757dd1 100644 --- a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt @@ -48,6 +48,7 @@ set(PROJECT_SOURCES if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(%{ProjectName} + MANUAL_FINALIZATION ${PROJECT_SOURCES} ) @if %{HasTranslation} @@ -77,3 +78,7 @@ set_target_properties(%{ProjectName} PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(%{ProjectName}) +endif()