diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-04-17 17:12:40 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-04-23 10:09:15 +0200 |
commit | 4545eadd3e28be4b04537cc71a8697da4421d918 (patch) | |
tree | 7784381372b51e27da11f25ee34ccfb34e297096 /cmake | |
parent | 1c7950081f926475bbdaa18379c2f51f99fcb3bb (diff) |
CMake: Port the 'static_runtime' feature
This feature is Windows-only and must be turned on manually.
For MSVC it sets the MSVC_RUNTIME_LIBRARY target property.
For MinGW it adds the -static linker flag.
Change-Id: I9da3b88d545b34bc34a3a80301b2dd1b5986fa88
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 11f00e5222..b3eafd8d9e 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1830,6 +1830,19 @@ endfunction() variable_watch(CMAKE_CURRENT_LIST_DIR qt_watch_current_list_dir) +# Set target properties that are the same for all modules, plugins, executables +# and 3rdparty libraries. +function(qt_set_common_target_properties target) + if(FEATURE_static_runtime) + if(MSVC) + set_property(TARGET ${target} PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") + elseif(MINGW) + target_link_options(${target} INTERFACE "LINKER:-static") + endif() + endif() +endfunction() + # This is the main entry function for creating a Qt module, that typically # consists of a library, public header files, private header files and configurable # features. @@ -1870,6 +1883,10 @@ function(qt_add_module target) add_library("${target}" STATIC) endif() + if(NOT is_interface_lib) + qt_set_common_target_properties(${target}) + endif() + set(is_framework 0) if(QT_FEATURE_framework AND NOT ${arg_HEADER_MODULE} AND NOT ${arg_STATIC}) set(is_framework 1) @@ -2739,6 +2756,8 @@ function(qt_internal_add_plugin target) endif() endif() + qt_set_common_target_properties(${target}) + # Make sure the Qt6 plugin library names are like they were in Qt5 qmake land. # Whereas the Qt6 CMake target names are like the Qt5 CMake target names. set(output_name "${target}") @@ -3039,6 +3058,7 @@ function(qt_add_executable name) qt6_generate_win32_rc_file(${name}) endif() + qt_set_common_target_properties(${name}) qt_autogen_tools_initial_setup(${name}) qt_skip_warnings_are_errors_when_repo_unclean("${name}") @@ -3522,6 +3542,10 @@ function(qt_add_3rdparty_library target) add_library("${target}") endif() + if(NOT arg_INTERFACE) + qt_set_common_target_properties(${target}) + endif() + if (NOT arg_ARCHIVE_INSTALL_DIRECTORY AND arg_INSTALL_DIRECTORY) set(arg_ARCHIVE_INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}") endif() |