summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-11-30 12:10:19 +1100
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-12-08 19:50:21 +0100
commit5cdc82e36469093fe577aeb95915a55b4cafa029 (patch)
treec95e7505126a53786c1cf278c7421b85bfe609a4 /src
parent22c92f39670d0376478cc2e73a17307508f86692 (diff)
Fall back to include() method for finalizers with CMake 3.17 or earlier
Functionality is being added in other repos which require finalizers to be run for non-static builds. That means we now need to ensure finalizers always run even with CMake versions before cmake_language() was added. The fallback method of writing to a file and including it is slower, but that's better than missing important functionality altogether. Task-number: QTBUG-98545 Pick-to: 6.2 Change-Id: Ic8668c91c26d0c30de084b1b803032088c10fcf4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index eafdd02695..1136fcbc5a 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -702,11 +702,15 @@ function(_qt_internal_finalize_executable target)
if(finalizers)
if(CMAKE_VERSION VERSION_LESS 3.18)
- # cmake_language() not available
- message(WARNING
- "Skipping module-specific finalizers for target ${target} "
- "(requires CMake 3.18 or later)"
- )
+ # cmake_language() not available, fall back to the slower method of
+ # writing a file and including it
+ set(contents "")
+ foreach(finalizer_func IN LISTS finalizers)
+ string(APPEND contents "${finalizer_func}(${target})\n")
+ endforeach()
+ set(finalizer_file "${CMAKE_CURRENT_BINARY_DIR}/.qt/finalize_${target}.cmake")
+ file(WRITE ${finalizer_file} "${contents}")
+ include(${finalizer_file})
else()
foreach(finalizer_func IN LISTS finalizers)
cmake_language(CALL ${finalizer_func} ${target})