-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically create alias targets in cmake [ESD-2467] #124
Automatically create alias targets in cmake [ESD-2467] #124
Conversation
… goal is to get aliases of all target
Update variable names
…tomaticallyCreateAliasTargetsInCmake
SwiftTargets.cmake
Outdated
@@ -184,6 +184,8 @@ define_property(TARGET | |||
BRIEF_DOCS "Target's source directory" | |||
FULL_DOCS "Identical use as SOURCE_DIR except that this applies to ALL target types, including INTERFACE") | |||
|
|||
set(project_alias "swiftnav" CACHE STRING "Alias for project") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe you need to make this a cache variable, the following will suffice:
set(SWIFTNAV_ALIAS swiftnav)
Also global variables are captialized
SwiftTargets.cmake
Outdated
endif() | ||
|
||
foreach(target_dependency ${target_dependencies}) | ||
if (TARGET ${target_dependency}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid the nesting you use the following technique:
if (TARGET ${target_dependency})
continue()
endif()
get_target_property(swift_dep_alias ${target_dependency} ALIASED_TARGET)
if (NOT swift_dep_alias)
continue()
endif()
get_target_property(target_dep_type ${target_dependency} TYPE)
...
if (NOT TARGET ${SWIFTNAV_ALIAS}::${target_dependency}) | ||
continue() | ||
endif() | ||
|
||
get_target_property(_swift_dep_alias ${SWIFTNAV_ALIAS}::${target_dependency} ALIASED_TARGET) | ||
if (NOT _swift_dep_alias) | ||
continue() | ||
endif() | ||
|
||
if (${_swift_dep_alias} STREQUAL ${target_dependency}) | ||
message(WARNING "Linking \"${target_dependency}\" as a dependency of target \"${target}\". Please use alias \"${SWIFTNAV_ALIAS}::${target_dependency}\" instead.") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra check to ensure the recommended alias is the real alias.
…tomaticallyCreateAliasTargetsInCmake
Kudos, SonarCloud Quality Gate passed! |
Jira ticket
https://swift-nav.atlassian.net/browse/ESD-2467
Design
swift_add_target()
to automatically create alias for all library targets, when callingswift_add_***_library()
.swift_validate_targets()
to return warning if swift target links to "not alias" dependencies.Related PRs