qt5base-lts/cmake/QtPublicToolHelpers.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

47 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
# The function returns location of the imported 'tool', returns an empty string if tool is not
# imported.
function(__qt_internal_get_tool_imported_location out_var tool)
unset(${out_var})
if("${tool}" MATCHES "^Qt[0-9]?::.+$")
# The tool target has namespace already
set(target ${tool})
else()
set(target ${QT_CMAKE_EXPORT_NAMESPACE}::${tool})
endif()
if(NOT TARGET ${target})
message(FATAL_ERROR "${target} is not a target.")
endif()
get_target_property(is_imported ${target} IMPORTED)
if(NOT is_imported)
set(${out_var} "" PARENT_SCOPE)
return()
endif()
get_target_property(configs ${target} IMPORTED_CONFIGURATIONS)
list(TRANSFORM configs PREPEND _)
# Well-known configuration types
list(APPEND configs
_RELWITHDEBINFO
_RELEASE
_MINSIZEREL
_DEBUG
)
list(REMOVE_DUPLICATES configs)
# Look for the default empty configuration type at the first place.
list(PREPEND configs "")
foreach(config ${configs})
get_target_property(${out_var} ${target} "IMPORTED_LOCATION${config}")
if(${out_var})
break()
endif()
endforeach()
set(${out_var} "${${out_var}}" PARENT_SCOPE)
endfunction()