diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-11-03 17:00:11 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-11-09 18:08:06 +0100 |
commit | ff170962d460aafea93373f8c2391716d199adb9 (patch) | |
tree | 7e2a1fcb81afcd2af359fec56621c2690999c3b4 /src/entrypoint/CMakeLists.txt | |
parent | c2e1a773e060ae34089f805eaab87394c5903a9e (diff) |
Don't rely on the module.pri for the entrypoint linking to the library
Depending on the presence and behavior of HEADER_MODULE/header_module
in CMake and qmake land, the module.pri might end up with an empty
module line, which means adding the module via QT_PRIVATE += entrypoint
will not link to the static library.
To avoid this problem we write an explicit module entry (QT.foo.bar)
into the same module.pri file as the one generated by qt_module,
where the auto-generated one has header_module enabled, and hence
no link behavior, while the manually written entry has a module
component, and will ensure linkage to the static library.
Change-Id: Ib98484f74410fab45c4d109f3610028200fba0c5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/entrypoint/CMakeLists.txt')
-rw-r--r-- | src/entrypoint/CMakeLists.txt | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/entrypoint/CMakeLists.txt b/src/entrypoint/CMakeLists.txt index add9023a7d..4045416dbf 100644 --- a/src/entrypoint/CMakeLists.txt +++ b/src/entrypoint/CMakeLists.txt @@ -25,16 +25,6 @@ set_target_properties(EntryPoint PROPERTIES INTERFACE_COMPILE_DEFINITIONS "" ) -# And since this module is the one producing the module pri, -# we need to manually tell it that what we're actually doing -# is producing a module that has a static library. -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 INCLUDE_DIRECTORIES @@ -69,7 +59,7 @@ if(WIN32) # linker line, so that the static linker will pick up the WinMain symbol # from the entry-point library. target_link_libraries(EntryPoint INTERFACE mingw32) - list(APPEND module_pri_entrypoint_ldflags "-lmingw32") + set_property(TARGET EntryPoint APPEND PROPERTY INTERFACE_QT_MODULE_LDFLAGS "-lmingw32") target_compile_definitions(EntryPoint INTERFACE QT_NEEDS_QMAIN) qt_internal_extend_target(EntryPointImplementation DEFINES QT_NEEDS_QMAIN) @@ -78,14 +68,22 @@ endif() # ---- Finally, make sure the static library can be consumed by clients ----- +target_link_libraries(EntryPoint INTERFACE EntryPointImplementation) + +qt_internal_get_target_property(entrypoint_implementation_ldflags + EntryPointImplementation QT_MODULE_LDFLAGS) + set_target_properties(EntryPoint PROPERTIES - INTERFACE_QT_MODULE_LDFLAGS "${module_pri_entrypoint_ldflags}" + INTERFACE_QT_MODULE_PRI_EXTRA_CONTENT " +QT.entrypoint_implementation.name = QtEntryPointImplementation +QT.entrypoint_implementation.module = Qt6EntryPoint +QT.entrypoint_implementation.ldflags = ${entrypoint_implementation_ldflags} +QT.entrypoint_implementation.libs = $$QT_MODULE_LIB_BASE +QT.entrypoint_implementation.module_config = staticlib v2 internal_module +" + INTERFACE_QT_MODULE_DEPENDS "entrypoint_implementation" ) -# 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) - set(export_name "${INSTALL_CMAKE_NAMESPACE}EntryPointTargets") qt_install(TARGETS EntryPointImplementation EXPORT ${export_name}) qt_generate_prl_file(EntryPointImplementation "${INSTALL_LIBDIR}") |