[CMake] Building multiple configurations with Xcode?

clinton at elemtech.com clinton at elemtech.com
Fri May 3 09:46:32 EDT 2013



----- Original Message -----
> clinton at elemtech.com wrote:
> 
> > 
> > 
> > ----- Original Message -----
> >> Stephen Kelly wrote:
> >> 
> >> > Is it possible to build multi-config frameworks with cmake at all?
> >> 
> >> I also notice that the Framework unit test uses
> >> 
> >>  set_target_properties(foo PROPERTIES
> >>    FRAMEWORK TRUE
> >>    DEBUG_POSTFIX -d
> >>  )
> >> 
> >> but the debug file is called 'foo', not 'foo-d'. If I use
> >> 
> >>  cmake --build . --target install --config Debug
> >>  cmake --build . --target install --config Release
> >> 
> >> the debug and release versions overwrite each other.
> >> 
> >> Does this mean it has always been broken? Has no one ever tried to create
> >> a framework using cmake?
> > 
> > In the build tree, I would expect "foo" not "foo-d" for the debug
> > framework.
> > And in the build tree, it is possible to differentiate the release from
> > debug simply by having two "foo.framework/foo".  One will be in the
> > Release folder and one in the Debug folder, and a Debug build will use the
> > one from the Debug folder, while the release build will use the one from
> > the Release folder.
> 
> That indeed appears to be what happens.

But, I personally don't see a problem with there being a "foo.framework/foo" and a "foo-d.framework/foo-d".
At install time, they would not overwrite each other and the export file would need to list both of them.

> 
> > 
> > For the install tree, I don't see how it is known which configurations
> > will be installed.
> 
> I'm not familiar with xcode, so I assumed that if you install it would
> install all configurations, or you would specify which you want to install.

Xcode works in one configuration at a time.
The install target is the same way, by installing only one configuration at a time.

> 
> When I use the command line I use
> 
>  cmake --build . --target install --config Debug
> 
> so it is specified.

That one configuration was specified, yes.  But it isn't known if the Release one will also be installed.
If it is known they are both being installed, and one wanted them to both go into the same framework, then the debug one can be renamed to and the burden put on the user to specify DYLD_IMAGE_SUFFIX to run their application with the debug library.
If only the Debug configuration is installed, and it was still renamed, you'd have a broken framework.

> 
> So, I don't know what you mean here. Can you be more specific, keeping in
> mind I don't know xcode?

The behavior is basically the same as visual studio, if you know that, with the addition of this framework concept.
While the whole build system supports multiple configurations, the user is only in one configuration at a given time.
In contrast, building Qt can be done with makefiles that compile multiple configurations at the same time, but in practice, that kind of setup seems rare.

> 
> Assuming there is some unavoidable reason that the configuration is not
> known when installing, does that mean that frameworks which contain a foo
> and a foo_debug can not be created by cmake?

Yeah, that would seem to be the case.  Unless someone has done it and can tell us how.
Again, I wouldn't mind having a foo.framework/foo and foo-d.framework/foo-d which avoids this whole problem.

> 
> I left a comment on the original Qt bug above that he should look into using
> DYLD_IMAGE_SUFFIX. Is that right?

That is the correct response in the context of Qt.

Clint


More information about the CMake mailing list