[CMake] Different targets for different configurations

Mike Krus mike at mve.com
Fri Mar 23 05:10:22 EDT 2012


On 23/03/2012 06:53, Eric Noulard wrote:
> Why can't you use the "PRE_BUILD" options of add_custom_command
> with TARGET target signature?
>
> It is not possible because this script should be run before any target?
I was looking at using targets do make sure the script only once and did 
so before any target. I supposed I could use it PRE_BUILD option of one 
of my libraries that everything else depends on...

Technically, that command could run when CMake is invoked (ie before any 
build invocation). In that case, if the generator is Visual Studio, I 
would simple run the script twice, once with parameters compatible for 
debug, once for release... Is there a way to do that?



>> >  Here's the CMake code below...
>> >
>> >
>> >  My problem is that for Visual Studio ${CMAKE_BUILD_TYPE} is not set (normal)
>> >  and CMake doesn't know about $(CONFIGURATION) since it's a build time thing
>> >  (again, normal).
>> >  So as it stands, the scripts always runs at every build because it's not
>> >  picking up the correct output file.
> Did have a look at "generator expressions" they are meant to be used
> in your precise case,
> i.e. they are evaluated at "build time" and not at CMake time.
well I can only use those for parameters for the command. I would want 
to specify a configuration dependant OUTPUT value.

I suppose I could do 2 commands, add a target for each of them.
But then how to do I do configuration dependent DEPEND rules when 
calling ADD_DEPENDENCIES for my other libs?



Mike

-- 
Mike Krus (PhD) - Principal Software Engineer

Midland Valley Exploration
144 West George Street
Glasgow G2 2HG, UK
Tel: +44 141 332 2681
Fax: +44 141 332 6792


More information about the CMake mailing list