qt5base-lts/cmake/QtPublicFinalizerHelpers.cmake
Lucie Gérard fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00

36 lines
1.4 KiB
CMake

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
# Helper to check if the finalizer mode should be used.
# If true, use finalizer mode.
# If false, use regular mode (usage requirement propagation via associated Qt module)
# Arguments:
# DEFAULT_VALUE specifies the default value of the finalizer mode flag if it is not set.
function(__qt_internal_check_finalizer_mode target out_var finalizer)
set(option_args "")
set(single_args DEFAULT_VALUE)
set(multi_args "")
cmake_parse_arguments(arg "${option_args}" "${single_args}" "${multi_args}" ${ARGN})
if(NOT DEFINED arg_DEFAULT_VALUE OR arg_DEFAULT_VALUE)
set(arg_DEFAULT_VALUE TRUE)
else()
set(arg_DEFAULT_VALUE FALSE)
endif()
get_target_property(value ${target} _qt_${finalizer}_finalizer_mode)
if("${value}" STREQUAL "value-NOTFOUND")
__qt_internal_enable_finalizer_mode(${target} ${finalizer} "${arg_DEFAULT_VALUE}")
set(value "${arg_DEFAULT_VALUE}")
endif()
set(${out_var} "${value}" PARENT_SCOPE)
endfunction()
function(__qt_internal_enable_finalizer_mode target finalizer enabled)
if(enabled)
set(enabled "TRUE")
else()
set(enabled "FALSE")
endif()
set_property(TARGET "${target}" PROPERTY _qt_${finalizer}_finalizer_mode "${enabled}")
endfunction()