[cmake-developers] Generator expressions for <archive|library|runtime> output directory

Ben Boeckel ben.boeckel at kitware.com
Tue Jul 21 11:24:15 EDT 2015


On Tue, Jul 21, 2015 at 10:03:42 -0400, Brad King wrote:
> Okay.  I've made a note about this issue to make sure it is fixed before 3.4.
> 
> Meanwhile I have another comment on genex support in the OUTPUT_DIRECTORY
> properties.  Currently the properties support both
> 
>  {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY
> 
> and
> 
>  {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY_<CONFIG>
> 
> variants.  When the former is used CMake will still add the /<CONFIG>
> directory suffix to the end of the value.  When the latter is used
> CMake does not do this.
> 
> With the former, when a genex like $<CONFIG> is used, it is likely
> that the user does not want CMake to add the /<CONFIG> suffix.
> Perhaps we should detect when a genex is present in the value and
> skip adding the suffix, thus trusting the user to have done the right
> thing (e.g. $<1:value> will still not get a suffix).

+1

The main use case I've come across is when generating modules for
languages using CMake. Generally, there you want:

    ${common_output_path}/$<CONFIG>/path/to/module.so

since the interpreter searches using the last path parts from the module
import (here, 'path.to.module').

The only way to reliable do it right is to iterate over
CMAKE_CONFIGURATION_TYPES and set the properties that way with
${CMAKE_CFGINT_DIR}.

> Of course this would have to be documented carefully.  We could also
> disallow a genex in the latter (per-config) variants to encourage
> modern use of the former.

+1

--Ben


More information about the cmake-developers mailing list