[cmake-developers] [CMake 0014768]: Using OBJECT libraries with Xcode causes incorrect builds

Mantis Bug Tracker mantis at public.kitware.com
Thu Feb 20 15:48:41 EST 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14768 
====================================================================== 
Reported By:                Paul Smith
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14768
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2014-02-20 15:48 EST
Last Modified:              2014-02-20 15:48 EST
====================================================================== 
Summary:                    Using OBJECT libraries with Xcode causes incorrect
builds
Description: 
I wanted to use an OBJECT library in order to build both a static and shared
library from the same set of objects, across multiple directories.  This works
great with Makefiles and Visual Studio but fails with Xcode: the initial build
works fine but if I then change a file and re-run the build it compiles the
object file but does NOT update the libraries and executables that depend on it.

Steps to Reproduce: 
CMakeLists.txt:
#----------
cmake_minimum_required(VERSION 2.8.12)
project(CMTEST CXX)

add_library(foo_OBJECTS OBJECT foo.cpp foo.h)

add_library(foo SHARED dummy.cpp $<TARGET_OBJECTS:foo_OBJECTS>)
add_dependencies(foo foo_OBJECTS)

add_executable(hello hello.cpp)
target_link_libraries(hello foo)
#----------

Then create a trivial foo.cpp, foo.h, and hello.cpp.
Run "cmake -G Xcode ."
Run "xcodebuild build -configuration RelWithDebInfo" (or use "cmake -build" if
you prefer).

All builds and is fine.

Now modify foo.cpp.
Run "xcodebuild build -configuration RelWithDebInfo" again (or "cmake -build")

Note that Xcode recompiles foo.o and updates libfoo_OBJECTS.a, _BUT_ it does NOT
recreate libfoo.a and it does not re-link the hello program.

Additional Information: 
I've tried this with Xcode 4.6 and Xcode 5.0.  I've tried it with CMake 2.8.12.2
and also with the latest CMake 3.0.0-rc1 from Git master; same behavior in all
situations.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-02-20 15:48 Paul Smith     New Issue                                    
======================================================================



More information about the cmake-developers mailing list