[cmake-developers] exports and MAP_IMPORTED_CONFIG_<CONFIG> (was: Policy for INTERFACE_LINK_LIBRARIES)

Brad King brad.king at kitware.com
Wed Dec 12 15:07:40 EST 2012


On 12/09/2012 08:48 AM, Stephen Kelly wrote:
> I think the 'Setting include directories via target_link_libraries() ?' 
> thread needs to be concluded first (with reasoning), as that affects 
> everything else.

While thinking about my next response to that discussion I realized
that most of our discussion so far about exported interfaces has missed
a major piece.  You briefly mentioned it while we discussed the syntax
of the $<CONFIG_DEBUG> expression.  It is MAP_IMPORTED_CONFIG_<CONFIG>:

 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt:MAP_IMPORTED_CONFIG_CONFIG

Every part of an exported interface (link interface libraries, include
dirs, compile definitions, etc.) potentially depends on the configuration
being exported from the project.  The exporting project knows nothing of
the importing projects' configurations.  All evaluation of its generator
expressions must be done using only one of the original configurations
for expressions like $<CONFIG:...>, $<CONFIG_DEBUG> and $<CONFIGURATION>.

One approach to this is to perform partial evaluation of all exported
interfaces to resolve generator expressions that depend on the config.
Then store the results in exported properties ending in _<CONFIG>.
This is essentially what CMake <= 2.8.10 does to produce properties
like IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>, but that is actually
full evaluation because there is no support for generator expressions.

The importing project then selects one of the exported configurations
using heuristics and MAP_IMPORTED_CONFIG_<CONFIG> if defined.

Another approach is to try to honor the configuration mapping while
evaluating exported generator expressions in the importing project.
Evaluation would need to track when it crosses into expressions that
came from another project and lookup the configuration mapping.

Note that the above holds for not only link interface libraries but
for any new usage requirements support too.  For example in the partial
evaluation approach the exported interfaces would need properties like

 (IMPORTED_)?INCLUDE_DIRECTORIES_<CONFIG>
 (IMPORTED_)?COMPILE_DEFINITIONS_<CONFIG>

Such properties are distinct from properties like INCLUDE_DIRECTORIES
in that they will not contain config-dependent generator expressions.

Comments?
-Brad



More information about the cmake-developers mailing list