[cmake-developers] Use linker build phase for Xcode 4 generator

Brad King brad.king at kitware.com
Tue Jun 4 09:38:17 EDT 2013


On 06/03/2013 03:38 PM, Nicolas Tessore wrote:
> As far as I can see, there is just one possible issue with this.
> Say there is "libfoo.a" in two locations, ie. "/usr/lib" and
> "/usr/local/lib". If "/usr/lib" comes first in LIBRARY_SEARCH_PATHS,
> it is impossible to link to "/usr/local/lib/libfoo.a".

A more common case like this is when a project uses two library
targets with the OUTPUT_NAME target property to produce a shared
and static library in the same directory with the same name e.g.
libfoo.a and libfoo.dylib.  Then -lfoo will not know which one
to get, but a full path specifies the right one exactly.

Issues like both of the above are why CMake wants precise control
over the link line and to use full paths.  We went through a lot
of trouble to clean this up back in version 2.6.0, and the need
for policy CMP0003 for compatibility led to the introduction of
policies in the first place.

> This is however a limitation of Xcode, and the
> same problem occurs when manually setting up a project.

CMake tries to work around limitations of the native build tools
when possible in order to achieve a uniform expectation for a
cross-platform build.

So we have a trade-off between correct one-time builds versus
correct cross-project rebuild dependencies.  I think your proposal
can be provided as an option (CMAKE_XCODE_LINK_WITH_BUILD_PHASE?)
for those that want to try it.  After gaining some experience with
projects building using the option it can help us choose default
behavior in the future.  Before diving deeper into the feature
implementation, let's hammer out some details here first.

I'm not sure what the generator should do when the option is on
but specific link items cannot be represented by the build phase,
such as --my-special-linker-flag.  Order is sometimes important.

-Brad



More information about the cmake-developers mailing list