[CMake] configuration specific ADD_CUSTOM_COMMAND
Bill Hoffman
bill.hoffman at kitware.com
Wed Mar 12 12:05:11 EDT 2008
Zschocke, Florian wrote:
>> From: Bill Hoffman [mailto:bill.hoffman at kitware.com]
>>
>> With the use of CMAKE_CFG_INTDIR, you should be able to get to the
>> targets you need inside custom commands with the multiconfiguration
>> build systems. Have you tried CVS CMake, I think that the LOCATION
> of
>> the target includes CMAKE_CFG_INTDIR in it.
>
> I can get the path of the target fine. I haven't tried the CVS CMake.
> Would you consider it stable enough for general use? I use 2.4.8 with a
> few patches.
>
> The CMAKE_CFG_INTDIR is part of the LOCATION in 2.4.8 (as far as I can
> see), so the path is not the problem. The problem is with using a
> DEBUG_POSTFIX. This is not honoured in LOCATION, I would have to use
> DEBUG_LOCATION for that. Which means that I have to somehow know myself
> in the script when to use LOCATION and when DEBUG_LOCATION.
>
> I guess what I am saying is that when CMake has a way of getting "the
> right" path, why can't it also get "the right" filename.
>
> By now I have given up on the DEBUG_POSTFIX and am using different
> directories again, which wasn't quite what I wanted originally.
>
OK, I get it now... Sorry I was not following the thread close enough.
I will have to think about this one. I think the only way to do this
would be to have custom commands that are specific to configurations. I
am not sure how LOCATION can work as it does not know what configuration
you will be using at build time, and there is no variable that gives the
name. I am not even sure there is a way to create such a variable. So,
being able to specify custom commands for a config type would be the
only way to fix this. If you want this to work right now, I think the
only way to do it would be this:
Use a cmake script to drive the custom command. The custom command
should run a cmake -P script. That script should take CMAKE_CFG_INTDIR
on the command line. cmake -DDEBUG_LOCATION=${DEBUG_LOCATION}
-DRELEASE_LOCATION=${RELEASE_LOCATION} -DCFG=${CMAKE_CFG_INTDIR} -P
myscript.cmake. The script should use the value of CFG to figure out
which location to use.
-Bill
More information about the CMake
mailing list