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,808
    • Issues 3,808
    • 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
  • #20698

Closed
Open
Created May 12, 2020 by alcroito@alcroitoDeveloper

Add feature to define custom variable-initialized properties like (CMAKE_AUTOMOC)

Initially asked on the forum, will post description here.

https://discourse.cmake.org/t/is-there-a-way-to-implement-a-feature-similar-to-cmake-my-var-for-setting-properties/1196

To disable some compile flags based on a target property, consumers of my library have to do something like the following:

find_package(Mylib)
add_executable(app_target)
target_link_libraries(app_target INTERFACE mylib::mylib)
set_target_properties(app_target PROPERTIES DISABLE_SPECIAL_FLAG 1)

and my library when created has something like the following

add_library(SHARED mylib)
set(genex_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:DISABLE_SPECIAL_FLAG>>>")
set(flags "$<${genex_condition}:-my-nice-flag>")
target_compile_options("mylib" INTERFACE "${flags}")

The above API forces users to explicitly set the DISABLE_SPECIAL_FLAG property on each target that is directly linking against mylib (I’m aware that users can work around it by linking publicly against their own interface library that sets it only once).

It would be nice if users could define something like CMAKE_AUTOMOC, where if the CMAKE_AUTOMOC variable is set in a scope, all targets created below that variable get their AUTOMOC property initialized to whatever is set in CMAKE_AUTOMOC.

So I’d like the user to set a GLOBAL_DISABLE_SPECIAL_FLAG variable to 1, and then the DISABLE_SPECIAL_FLAG property is automatically populated with 1 for all targets created below that statement.

Perhaps it could be done via a command call rather than a variable.

Something like: add_properties(PROPERTY_NAME "value"), and all targets created within this scope and later would have that property set.

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