Provide namespaced CMake targets #4737
Merged
+12
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Projects (e.g. msh3) that use CMake targets from dependencies (here: msquic) should use namespaced target names from those dependencies. This enables CMake to recognize the intention to use a target, not a library name. CMake can report a missing target definition early (at generation time), instead of creating linker instruction which may fail at build time.
msquic already added namespace
msquic::
to the exported CMake config. However, this should be complemented withmsquic::
ALIAS
targets inside the build, for reverse dependencies which integrate msquic viaadd_subdirectory
. This PR adds the missing targets.In addition the PR shortens the exported name of
msquic_platform
tomsquic::platform
.The
msquic::base_link
alias is added for use in msh3. (This nicely illustrate how the namespace clarifies the origin ofbase_link
.)Testing
Covered by src/platform/unittest/external/CMakeLists.txt.
The msquic/msh3 integration with namespaced targets is tested in https://github.com/microsoft/vcpkg/pull/43018/files, with a DLL build of msquic passed to msh3 via CMake config.(Blocked.)Documentation
No change due to lack of specific CMake usage documentation.
(vcpkg prints an generated hint which will need to be reduced to linking
msquic::msquic
.)