CMake: Define QT_STATIC for static builds
QT_STATIC must be defined for static builds to have the right import/export symbol macros defined. Originally, this macro is wrapped in a condition. That's why we extend qt_feature_definition to be able to write a prerequisite to qconfig.h. Change-Id: I610e60acc7f5bdc031eff6d53a76e0b229a5c8c2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
c20f23e03b
commit
7909de1beb
@ -343,7 +343,7 @@ endfunction()
|
||||
|
||||
function(qt_feature_definition feature name)
|
||||
qt_feature_normalize_name("${feature}" feature)
|
||||
qt_parse_all_arguments(arg "qt_feature_definition" "NEGATE" "VALUE" "" ${ARGN})
|
||||
qt_parse_all_arguments(arg "qt_feature_definition" "NEGATE" "VALUE;PREREQUISITE" "" ${ARGN})
|
||||
|
||||
# Store all the define related info in a unique variable key.
|
||||
set(key_name "_QT_FEATURE_DEFINE_DEFINITION_${feature}_${name}")
|
||||
@ -363,7 +363,7 @@ function(qt_evaluate_feature_definition key)
|
||||
|
||||
cmake_parse_arguments(arg
|
||||
"NEGATE;"
|
||||
"FEATURE;NAME;VALUE;" "" ${${key}})
|
||||
"FEATURE;NAME;VALUE;PREREQUISITE" "" ${${key}})
|
||||
|
||||
set(expected ON)
|
||||
if (arg_NEGATE)
|
||||
@ -373,10 +373,18 @@ function(qt_evaluate_feature_definition key)
|
||||
set(msg "")
|
||||
|
||||
if(QT_FEATURE_${arg_FEATURE} STREQUAL expected)
|
||||
set(indent "")
|
||||
if(arg_PREREQUISITE)
|
||||
string(APPEND msg "#if ${arg_PREREQUISITE}\n")
|
||||
set(indent " ")
|
||||
endif()
|
||||
if (arg_VALUE)
|
||||
string(APPEND msg "#define ${arg_NAME} ${arg_VALUE}\n")
|
||||
string(APPEND msg "${indent}#define ${arg_NAME} ${arg_VALUE}\n")
|
||||
else()
|
||||
string(APPEND msg "#define ${arg_NAME}\n")
|
||||
string(APPEND msg "${indent}#define ${arg_NAME}\n")
|
||||
endif()
|
||||
if(arg_PREREQUISITE)
|
||||
string(APPEND msg "#endif\n")
|
||||
endif()
|
||||
|
||||
string(APPEND __QtFeature_public_extra "${msg}")
|
||||
|
@ -321,6 +321,7 @@ qt_feature("shared" PUBLIC
|
||||
AUTODETECT NOT UIKIT
|
||||
CONDITION BUILD_SHARED_LIBS
|
||||
)
|
||||
qt_feature_definition("shared" "QT_STATIC" NEGATE PREREQUISITE "!defined(QT_SHARED) && !defined(QT_STATIC)")
|
||||
qt_feature_config("shared" QMAKE_PUBLIC_QT_CONFIG)
|
||||
qt_feature_config("shared" QMAKE_PUBLIC_CONFIG)
|
||||
qt_feature("use_bfd_linker"
|
||||
|
@ -827,7 +827,20 @@ def get_feature_mapping():
|
||||
"sanitizer": None,
|
||||
"sanitize_thread": None,
|
||||
"sanitize_undefined": None,
|
||||
"shared": {"condition": "BUILD_SHARED_LIBS"},
|
||||
"shared": {
|
||||
"condition": "BUILD_SHARED_LIBS",
|
||||
"output": [
|
||||
"publicFeature",
|
||||
"publicQtConfig",
|
||||
"publicConfig",
|
||||
{
|
||||
"type": "define",
|
||||
"name": "QT_STATIC",
|
||||
"prerequisite": "!defined(QT_SHARED) && !defined(QT_STATIC)",
|
||||
"negative": True
|
||||
}
|
||||
]
|
||||
},
|
||||
"silent": None,
|
||||
"sql-sqlite": {"condition": "QT_FEATURE_datestring"},
|
||||
"static": None,
|
||||
@ -1050,6 +1063,8 @@ def parseFeature(ctx, feature, data, cm_fh):
|
||||
cm_fh.write(" NEGATE")
|
||||
if outputArgs.get("value") is not None:
|
||||
cm_fh.write(f' VALUE "{outputArgs.get("value")}"')
|
||||
if outputArgs.get("prerequisite") is not None:
|
||||
cm_fh.write(f' PREREQUISITE "{outputArgs.get("prerequisite")}"')
|
||||
cm_fh.write(")\n")
|
||||
|
||||
# Write qt_feature_config() calls
|
||||
|
Loading…
Reference in New Issue
Block a user