Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,807
    • Issues 3,807
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #23135

Closed
Open
Created Jan 21, 2022 by Kostas Dizas@kostasdizas

Feature Request: Enhanced target_link_libraries validation

target_link_libraries supports an array of different types of 'items' which makes it easy to construct the input to the linker. However, this means it is impossible to validate what is linked to a target until the linker actually uses this input. So far I've only been able to do this using add_dependencies, but that introduces redundancies in the code and unnecessary duplications.

I'd like to propose a variant of this command that only accepts valid targets, similarly to add_dependencies, for the purposes of linking. Possibly, target_link_target although better ideas are welcome.

For example:

add_library(a)
add_library(b)
target_link_target(a PUBLIC b)
target_link_target(a PUBLIC c) # fails with 'The dependency target "c" of target "a" does not exist'

This will ensure at configuration time that all the target dependencies are accounted for. Additionally, it will provide some visual separation between target relationships and plaintext linker options that are currently combined with target_link_libraries.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking