Just discovered a bug in the Xcode generator; this works fine with Makefile generator (on OSX or Linux) and Visual Studio, but fails on Xcode:
$ cat CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(BadXcode) add_library(obj OBJECT foo.cpp) add_library(shared SHARED $<TARGET_OBJECTS:libobj>) $ touch foo.cpp $ mkdir obj $ cd obj $ cmake -G Xcode .. $ cmake --build . The build succeeds, but it never creates the libshared.dylib file: $ find . -name lib\* ./BadXcode.build/Debug/obj.build/Objects-normal/libobj.a I'm not sure why we're creating a .a here, when we're making an OBJECT library, but whatever... the main thing is there's no libshared.dylib: $ find . -name \*.dylib $ find . -name \*shared\* ./BadXcode.build/Debug/shared.build ./CMakeScripts/shared_postBuildPhase.makeDebug ./CMakeScripts/shared_postBuildPhase.makeMinSizeRel ./CMakeScripts/shared_postBuildPhase.makeRelease ./CMakeScripts/shared_postBuildPhase.makeRelWithDebInfo If I use the Makefile generator instead, it works as expected: $ rm -rf * $ cmake .. $ cmake --build . Scanning dependencies of target obj [ 50%] Building CXX object CMakeFiles/obj.dir/foo.cpp.o [ 50%] Built target obj Scanning dependencies of target shared [100%] Linking CXX shared library libshared.dylib [100%] Built target shared $ find . -name lib\* ./libshared.dylib -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake