kmpkg_check_linkage
Asserts the available library and CRT linkage options for the port.
Usage
kmpkg_check_linkage(
[ONLY_STATIC_LIBRARY | ONLY_DYNAMIC_LIBRARY]
[ONLY_STATIC_CRT | ONLY_DYNAMIC_CRT]
)
Parameters
ONLY_STATIC_LIBRARY
Indicates that this port can only be built with static library linkage.
If the user requested a dynamic build, ONLY_STATIC_LIBRARY will result in a note being printed,
not a fatal error.
ONLY_DYNAMIC_LIBRARY
Indicates that this port can only be built with dynamic/shared library linkage. When using this
option, port authors should add !(static & staticcrt) to the "supports" expression in the
port's kmpkg.json to warn consumers it will fail early.
ONLY_STATIC_CRT
Indicates that this port can only be built with static CRT linkage.
ONLY_DYNAMIC_CRT
Indicates that this port can only be built with dynamic/shared CRT linkage.
Notes
If the triplet requests a setting of KMPKG_LIBRARY_LINKAGE different than the port supports,
and changing KMPKG_LIBRARY_LINKAGE to that the port supports is considered safe,
kmpkg_check_linkage changes KMPKG_LIBRARY_LINKAGE to that the port supports and emits a warning.
This means that the port may produce something that the user does not expect, but the alternative
would be to just fail.
If kmpkg_check_linkage would change KMPKG_LIBRARY_LINKAGE to dynamic while the triplet
requests KMPKG_CRT_LINKAGE of static, the change is not considered safe and
kmpkg_check_linkage fails. Building a dynamic library with a static CRT creates conditions many
developers find surprising, and for which most ports are unprepared.
For example, on Windows, each DLL will get its own copy of the CRT, meaning such DLLs cannot share standard library components over the DLL boundary. On non-Windows, different .sos or .dylibs may cause mutually incompatible symbols from different CRT versions to be concurrently loaded.
If you are consuming a port and it fails in kmpkg_check_linkage, consider choosing a triplet that
sets KMPKG_CRT_LINKAGE to dynamic. If you really know what you're doing, understand the
potential problems a static CRT with a dynamic library can cause, and are confident that the port
safely handles that configuration, author a custom triplet which explicitly sets
KMPKG_LIBRARY_LINKAGE to dynamic and KMPKG_CRT_LINKAGE to static. For example:
if("${PORT}" STREQUAL "the-name-of-the-port-you-want-to-control")
set(KMPKG_LIBRARY_LINKAGE dynamic)
set(KMPKG_CRT_LINKAGE static)
endif()