Skip to content

INTERFACE target to set configurations for all targets #787

@NovaNekmit

Description

@NovaNekmit

Suggested enhancement

Add a cmake target, e.g. tfpsacrypto_config that all (sub)targets link against, so custom target configuration (target_include_directories, target_compile_definitions, ...) can be set in a central location.

In mbedtls 3.6 this was possible by adding the config into mbedcrypto, but with the PSA split, that was fragmented into many targets (e.g. platform).

Justification

TF-PSA-Crypto needs this because sometimes it is needed to add additional target configuration specific to just one module (TF-PSA-Crypto).

Using the global configuration (include_directories) is undesirable because it also affects other modules.

Currently one can manually inject the dependency into all targets (including the object libraries like platform), but having a central place would be better than needing to hardcode a list of (more or less internal) targets.

In my specific usecase, instead of a monolithing config file, the user-config is composed from fragments in various modular HALs depending on what is required.

set(TF_PSA_CRYPTO_USER_CONFIG_FILE "user_config.h")  # includes several other headers, like "my_hal_user_config.h"
add_subdirectory(${MBEDTLS_DIR})
target_include_directories(tfpsacrypto_config INTERFACE
  ${CMAKE_CURRENT_LIST_DIR}/config  # for user_config.h
)
target_link_libraries(tfpsacrypto_config INTERFACE
  my_hal  # adds include directory for my_hal_user_config.h, and provides HAL functions
  ...
)

Note that in the above example, one could set absolute paths for the headers (set(TF_PSA_CRYPTO_USER_CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/user_config.h") ), but this does not scale well, especially when HALs include other HALs (e.g. a platform-specific HAL that includes multiple sub-modules depending on SDK configuration flags).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsize-mEstimated task size: medium (~1w)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions