DziubanMaciej / cmag

Interactive analyzer and browser for CMake build systems
MIT License
1 stars 0 forks source link

Handle genexes evaluated based on target #41

Open DziubanMaciej opened 10 months ago

DziubanMaciej commented 10 months ago

There are some generator expressions, which are evaluated differently based on the target they are bound to.

  1. $<LINK_LANGUAGES:languages> (required for https://github.com/DziubanMaciej/cmag/issues/40)
  2. $<LINK_LANGUAGE>
  3. $<LINK_LANG_AND_ID:language,compiler_ids>
  4. $<COMPILE_LANGUAGE:languages>
  5. $<COMPILE_LANGUAGE>
  6. $<COMPILE_LANG_AND_ID:language,compiler_ids>

First problem: they cannot be be evaluated with $<TARGET_GENEX_EVAL>. Not sure why, because it technically has all the context required, but it just doesn't work. We cannot know in advance that a property will contain one of these genexes and remove it in the postamble.

Second problem: these properties will evaluate to different values when used in INTERFACE_LINK_LIBRARIES. Resulting value will depend on the language of target using this interface. We'll probably have to walk through all dependencies to resolve that properly.

Third problem (extension of the second): can it be transitive?

DziubanMaciej commented 10 months ago

My first thought was to add a new CMake pass, just to process LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES. In the main pass we'd dump unevaluated properties, process them in C++ (resolve problematic genexes) and then feed them back to CMake for a second pass to evaluate rest of the properties.

This is ok, for LINK_LIBRARIES, but to resolve INTERFACE_LINK_LIBRARIES, we need to know the dependencies, which we won't have at this point... Another pass? Some magical field in CmagTarget? This is hard...