[CMake] CMAKE_CFG_INTDIR

clinton at elemtech.com clinton at elemtech.com
Thu Sep 18 10:02:57 EDT 2014



----- Original Message -----
> On 15/09/14 12:01, Daniele E. Domenichelli wrote:
> > Is there an alternative variable for CMAKE_CFG_INTDIR that can be used
> > in configure time, instead of build time?
> > 
> > If there is not, is it safe to assume that the name of the directory is
> > equal to the name of the current configuration?
> 
> 
> Bump?
> 
> What I would like to do is to be able to change
> CMAKE_RUNTIME_OUTPUT_DIRECTORY (and similar variables) with something
> that contains the current configuration directory, i.e.
> 
>   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY .../${CMAKE_CFG_INTDIR}/...)
> 
> but unfortunately CMAKE_CFG_INTDIR causes an error when targets are
> installed.

As expected, that will not work.  CMAKE_CFG_INTDIR can give the build tool a variable, which is expanded by the build tool, and you've effectively added another configuration directory level.
You could end up with a directory such as
/path/to/Debug/Debug/


> 
> I was able to have something that works as I expect by doing this:
> 
>   foreach(config ${CMAKE_CONFIGURATION_TYPES})
>     string(TOUPPER ${config} CONFIG)
>     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} .../${config}/...)
>   endforeach()
> 
> But I was wondering if it is safe to assume that the current directory
> is always "${config}" or if it might be different.
> 

That should work just fine.  CMAKE_CONFIGURATION_TYPES gives you a list of all possible configuration that can be chosen at build time.

Clint



More information about the CMake mailing list