Allow adding linker flags to qmake module pris
The flags go before the library in the final linker line, as opposed to the dependencies declared in LIBS. This allows us to declare the flags for the entrypoint in the project file of the entrypoint, instead of in a standalone prf. Change-Id: I35c054fe9fdaa6add7cd0e8ba3f7304f975ff80f Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
2096463afc
commit
6032a9ca1a
@ -150,9 +150,11 @@ function(qt_generate_module_pri_file target)
|
||||
"${property_prefix}QT_MODULE_USES")
|
||||
get_target_property(module_pri_extra_content "${target}"
|
||||
"${property_prefix}QT_MODULE_PRI_EXTRA_CONTENT")
|
||||
get_target_property(module_ldflags "${target}"
|
||||
"${property_prefix}QT_MODULE_LDFLAGS")
|
||||
|
||||
foreach(var enabled_features disabled_features enabled_private_features disabled_private_features
|
||||
module_internal_config module_uses module_pri_extra_content)
|
||||
module_internal_config module_uses module_pri_extra_content module_ldflags)
|
||||
if(${var} STREQUAL "${var}-NOTFOUND")
|
||||
set(${var} "")
|
||||
else()
|
||||
@ -265,6 +267,7 @@ function(qt_generate_module_pri_file target)
|
||||
QT.${config_module_name}.name = ${module}
|
||||
QT.${config_module_name}.module = ${module_name_in_pri}${QT_LIBINFIX}
|
||||
QT.${config_module_name}.libs = $$QT_MODULE_LIB_BASE
|
||||
QT.${config_module_name}.ldflags = ${module_ldflags}
|
||||
QT.${config_module_name}.includes = ${public_module_includes}
|
||||
QT.${config_module_name}.frameworks = ${public_module_frameworks}
|
||||
QT.${config_module_name}.bins = $$QT_MODULE_BIN_BASE${module_plugin_types_assignment}
|
||||
|
@ -1,11 +1,2 @@
|
||||
qt:!console:contains(TEMPLATE, ".*app") {
|
||||
# This library needs to come before the entry-point library in the
|
||||
# linker line, so that the static linker will pick up the WinMain
|
||||
# symbol from the entry-point library. Unfortunately qmake and the
|
||||
# module system doesn't allow specifying linker flags or dependencies
|
||||
# as part of the module that end up _before_ the library itself, so
|
||||
# we have to work around it by declaring the dependency here.
|
||||
mingw: LIBS += -lmingw32
|
||||
|
||||
qt:!console:contains(TEMPLATE, ".*app"): \
|
||||
QT_PRIVATE += entrypoint_private
|
||||
}
|
||||
|
@ -180,6 +180,7 @@ for(ever) {
|
||||
MODULE_NAME = $$eval(QT.$${QTLIB}.name)
|
||||
MODULE_MODULE = $$eval(QT.$${QTLIB}.module)
|
||||
MODULE_INCLUDES = $$eval(QT.$${QTLIB}.includes)
|
||||
MODULE_LDFLAGS = $$eval(QT.$${QTLIB}.ldflags)
|
||||
MODULE_LIBS = $$eval(QT.$${QTLIB}.libs)
|
||||
MODULE_FRAMEWORKS = $$eval(QT.$${QTLIB}.frameworks)
|
||||
MODULE_USES = $$eval(QT.$${QTLIB}.uses)
|
||||
@ -200,6 +201,9 @@ for(ever) {
|
||||
|
||||
MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS
|
||||
|
||||
# Add linker flags before lib
|
||||
LIBS$$var_sfx += $$MODULE_LDFLAGS
|
||||
|
||||
# Frameworks shouldn't need include paths, but much code does not use
|
||||
# module-qualified #includes, so by default we add paths which point
|
||||
# directly into the frameworks. Private modules have somewhat convoluted
|
||||
|
@ -135,6 +135,7 @@ defineReplace(qtExportLibsForModule) {
|
||||
"" \
|
||||
"QT.$${MODULE_ID}.name = $$TARGET" \
|
||||
"QT.$${MODULE_ID}.module = $$module_module" \
|
||||
"QT.$${MODULE_ID}.ldflags = $$MODULE_LDFLAGS" \
|
||||
"QT.$${MODULE_ID}.libs = $$module_libs" \
|
||||
$$module_master \
|
||||
"QT.$${MODULE_ID}.includes = $$MODULE_INCLUDES" \
|
||||
|
@ -32,6 +32,8 @@ set_target_properties(EntryPoint PROPERTIES
|
||||
INTERFACE_QT_MODULE_INTERNAL_CONFIG "staticlib"
|
||||
)
|
||||
|
||||
set(module_pri_entrypoint_ldflags "")
|
||||
|
||||
|
||||
# ---- While the static library target does the work ----
|
||||
qt_internal_add_cmake_library(EntryPointImplementation STATIC
|
||||
@ -65,9 +67,10 @@ if(WIN32)
|
||||
if(MINGW)
|
||||
# The mingw32 library needs to come before the entry-point library in the
|
||||
# linker line, so that the static linker will pick up the WinMain symbol
|
||||
# from the entry-point library. The logic is duplicated in entrypoint.prf
|
||||
# on the qmake side.
|
||||
# from the entry-point library.
|
||||
target_link_libraries(EntryPoint INTERFACE mingw32)
|
||||
list(APPEND module_pri_entrypoint_ldflags "-lmingw32")
|
||||
|
||||
target_compile_definitions(EntryPoint INTERFACE QT_NEEDS_QMAIN)
|
||||
qt_internal_extend_target(EntryPointImplementation DEFINES QT_NEEDS_QMAIN)
|
||||
endif()
|
||||
@ -75,6 +78,10 @@ endif()
|
||||
|
||||
# ---- Finally, make sure the static library can be consumed by clients -----
|
||||
|
||||
set_target_properties(EntryPoint PROPERTIES
|
||||
INTERFACE_QT_MODULE_LDFLAGS "${module_pri_entrypoint_ldflags}"
|
||||
)
|
||||
|
||||
# Must be added last, so that any library dependencies added above will
|
||||
# precede the entrypoint library at link time.
|
||||
target_link_libraries(EntryPoint INTERFACE EntryPointImplementation)
|
||||
|
@ -23,6 +23,11 @@ win32 {
|
||||
mingw {
|
||||
DEFINES += QT_NEEDS_QMAIN
|
||||
MODULE_DEFINES += QT_NEEDS_QMAIN
|
||||
|
||||
# This library needs to come before the entry-point library in the
|
||||
# linker line, so that the static linker will pick up the WinMain
|
||||
# symbol from the entry-point library.
|
||||
MODULE_LDFLAGS += -lmingw32
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user