diff options
Diffstat (limited to 'cmake/QtPublicTargetHelpers.cmake')
-rw-r--r-- | cmake/QtPublicTargetHelpers.cmake | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/cmake/QtPublicTargetHelpers.cmake b/cmake/QtPublicTargetHelpers.cmake index 8f6c434c4e..02d5546560 100644 --- a/cmake/QtPublicTargetHelpers.cmake +++ b/cmake/QtPublicTargetHelpers.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + function(__qt_internal_strip_target_directory_scope_token target out_var) # In CMake versions earlier than CMake 3.18, a subdirectory scope id is appended to the # target name if the target is referenced in a target_link_libraries command from a @@ -304,7 +307,31 @@ function(_qt_internal_set_up_static_runtime_library target) set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") elseif(MINGW) - target_link_options(${target} INTERFACE "LINKER:-Bstatic") + get_target_property(target_type ${target} TYPE) + if(target_type STREQUAL "EXECUTABLE") + set(link_option PRIVATE) + else() + set(link_option INTERFACE) + endif() + if(CLANG) + target_link_options(${target} ${link_option} "LINKER:-Bstatic") + else() + target_link_options(${target} ${link_option} "-static") + endif() endif() endif() endfunction() + +function(_qt_internal_warn_about_example_add_subdirectory) + # This is set by qt_build_repo_impl_examples() in QtBuildRepoHelpers.cmake, only for developer + # builds, to catch examples that are added via add_subdirectory instead of via + # qt_internal_add_example. + if(QT_WARN_ABOUT_EXAMPLE_ADD_SUBDIRECTORY) + get_filename_component(dir_name "${PROJECT_SOURCE_DIR}" NAME) + message(AUTHOR_WARNING + "It looks like this example project was added via add_subdirectory instead of via " + "qt_internal_add_example. This causes issues in certain build configurations. Please " + "change the code to use\n qt_internal_add_example(${dir_name})\ninstead." + ) + endif() +endfunction() |