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>
This commit is contained in:
parent
1c7950081f
commit
4545eadd3e
@ -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()
|
||||
|
@ -794,6 +794,14 @@ qt_feature("ccache"
|
||||
CONDITION QT_USE_CCACHE
|
||||
)
|
||||
qt_feature_config("ccache" QMAKE_PRIVATE_CONFIG)
|
||||
qt_feature("static_runtime"
|
||||
LABEL "Statically link the C/C++ runtime library"
|
||||
AUTODETECT OFF
|
||||
CONDITION NOT QT_FEATURE_shared
|
||||
EMIT_IF WIN32
|
||||
)
|
||||
qt_feature_config("static_runtime" QMAKE_PUBLIC_CONFIG)
|
||||
qt_feature_config("static_runtime" QMAKE_PUBLIC_QT_CONFIG)
|
||||
qt_feature("dlopen" PRIVATE
|
||||
LABEL "dlopen()"
|
||||
CONDITION UNIX
|
||||
|
@ -907,7 +907,6 @@ def get_feature_mapping():
|
||||
},
|
||||
"silent": None,
|
||||
"sql-sqlite": {"condition": "QT_FEATURE_datestring"},
|
||||
"static_runtime": None,
|
||||
"stl": None, # Do we really need to test for this in 2018?!
|
||||
"strip": None,
|
||||
"sun-libiconv": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user