[CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
Paul Smith
paul at mad-scientist.net
Thu Jan 23 08:03:17 EST 2014
Hi all. I'm using CMake 2.8.12.1 on Linux, MacOS, and Windows. I've
discovered a bug in the Xcode generator when dealing with OBJECT and
STATIC libraries. This example works fine on Linux, and on MacOS with
the Makefile generator. I also haven't noticed a problem on Windows
(MSVC).
What I'm doing is creating an OBJECT library then creating a STATIC
library from that (and I'm also creating a SHARED library from the same
OBJECT library, but that's not relevant to this bug).
Here's the test file:
cmake_minimum_required(VERSION 2.8.12)
project(TestLib C)
add_library(mylib_OBJECTS OBJECT mylib.c)
add_library(mylib STATIC $<TARGET_OBJECTS:mylib_OBJECTS>)
add_executable(libtest libtest.c)
target_link_libraries(libtest mylib)
I have trivial mylib.c and libtest.c files.
The Makefile generators work fine; the libmylib.a library is created and
linked to libtest just as you'd expect.
For Xcode, though, the link fails:
Ld Debug/libtest normal x86_64
cd /Users/build/xcode-bug
/Developer/usr/bin/llvm-gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/build/xcode-bug/Debug -F/Users/build/xcode-bug/Debug -filelist /Users/build/xcode-bug/TestLib.build/Debug/libtest.build/Objects-normal/x86_64/libtest.LinkFileList -mmacosx-version-min=10.7 -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/build/xcode-bug/Debug/libmylib.a -o /Users/build/xcode-bug/Debug/libtest
Command /Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
The reason this fails is that while the link line is correctly trying to
link the Debug/libmylib.a library, the library that Xcode actually built
is quite different:
$ find . -name libmylib\*
./TestLib.build/Debug/mylib_OBJECTS.build/Objects-normal/libmylib_OBJECTS.a
This is not right.
Cheers!
More information about the CMake
mailing list