Function portal_add_dependency¶
Adds a dependency to a Portal module, handling both Portal and external dependencies.
This function abstracts the process of finding and linking dependencies, with special handling for Portal Framework modules.
Synopsis¶
portal_add_dependency(<module_name> <dependency>
[PORTAL]
[SKIP_LINK]
[LINK <target>]
[PORTAL_FIND_PACKAGE]
[FIND_PACKAGE_ARGS <arg>...])
Arguments¶
<module_name>Name of the Portal module (without
portal-prefix) that depends on the dependency.<dependency>Name of the dependency to add.
PORTALOptional flag indicating this is a Portal Framework module dependency. Changes the default link target to
portal::<dependency>and alters find_package behavior.SKIP_LINKOptional flag to skip the
target_link_librariescall. Useful when you only need to find the package but not link against it.LINK <target>Optional. Explicitly specify the link target name. If not provided:
For Portal dependencies (
PORTALflag): defaults toportal::<dependency>For external dependencies: defaults to
<dependency>::<dependency>
PORTAL_FIND_PACKAGEOptional flag indicating that
find_packageshould be called for a Portal dependency. Only used whenPORTALis set.FIND_PACKAGE_ARGS <arg>...Optional arguments to pass to
find_package(). Defaults toCONFIG REQUIRED.
Behavior¶
The function performs the following operations:
Link Target Determination: Determines the appropriate link target based on whether it’s a Portal or external dependency.
Package Finding:
For Portal dependencies with
PORTAL_FIND_PACKAGE: callsfind_package(portal-<dependency> CONFIG REQUIRED)For Portal dependencies without
PORTAL_FIND_PACKAGE: skips find_package (assumes in-tree build)For external dependencies: calls
find_package(<dependency> <args>)
Linking: Links the dependency to
portal-<module_name>as a PUBLIC dependency, unlessSKIP_LINKis specified.
Example Usage¶
Adding an external dependency:
portal_add_dependency(core spdlog)
# Calls: find_package(spdlog CONFIG REQUIRED)
# Links: target_link_libraries(portal-core PUBLIC spdlog::spdlog)
Adding a Portal module dependency (in-tree):
portal_add_dependency(engine core PORTAL)
# Skips find_package (assumes in-tree)
# Links: target_link_libraries(portal-engine PUBLIC portal::core)
Adding a Portal module dependency (installed):
portal_add_dependency(engine core PORTAL PORTAL_FIND_PACKAGE)
# Calls: find_package(portal-core CONFIG REQUIRED)
# Links: target_link_libraries(portal-engine PUBLIC portal::core)
Custom link target and find_package arguments:
portal_add_dependency(engine Vulkan
LINK Vulkan::Vulkan
FIND_PACKAGE_ARGS REQUIRED COMPONENTS Vulkan)
Notes¶
All dependencies are linked as PUBLIC to propagate to dependent targets
See Also¶
portal_add_module: Main module creation function that uses this internally