Re: [CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
On Thu, 2014-01-23 at 11:40 -0500, Brad King wrote: > On 01/23/2014 11:36 AM, Paul Smith wrote: > > I see. That's a shame :-(. > > Unfortunately it is an Xcode limitation that CMake cannot work around. > > > Kind of unpleasant. Anyone have any ideas? > > Add an "empty.c" source protected by if(XCODE). Yeah, I thought about that. Tested it here and it worked. OK, I can manage that. Plus it gives me a handy place to put a snarky comment about Xcode :-p :-) > Also be sure to set the POSITION_INDEPENDENT_CODE target property > on the object libraries to make sure the objects can be used in > a shared library. I've been adding -fPIC by hand but this property looks nicer; I'll check it out. Thanks Brad! -- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
On Thu, 2014-01-23 at 10:22 -0500, Brad King wrote: > On Thu, Jan 23, 2014 at 8:03 AM, Paul Smith wrote: > > add_library(mylib STATIC $) > [snip] > > The Makefile generators work fine > > > > For Xcode, though, the link fails: > > This is a known limitation. From the add_library documentation: > > http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library > "Some native build systems may not like targets that have only object files, > so consider adding at least one real source file" I see. That's a shame :-(. I have lots of these libraries and so I was trying to write a macro that would do all this stuff for me (create the OBJECT library then the STATIC library, plus it does a few other things I need done like set certain properties). Then later in one CMakeLists.txt file I would collect all the OBJECT libraries into a single SHARED library, like: set(SO_OBJECTS) foreach(LIB lib1 lib2 lib3 lib4) list(APPEND SO_OBJECTS $) endforeach() That worked great--for makefile generators. If I have to exclude one of the source files from the OBJECT library so I can include it directly into the STATIC library, now somehow I have to also remember that extra source file so it can be included in the SHARED library as well. Also, doesn't that mean that I'll be compiling those source files which are omitted from the OBJECT library twice, once for shared and once for static? Kind of unpleasant. Anyone have any ideas? -- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
On 01/23/2014 11:36 AM, Paul Smith wrote: > I see. That's a shame :-(. Unfortunately it is an Xcode limitation that CMake cannot work around. > Kind of unpleasant. Anyone have any ideas? Add an "empty.c" source protected by if(XCODE). Also be sure to set the POSITION_INDEPENDENT_CODE target property on the object libraries to make sure the objects can be used in a shared library. -Brad -- 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://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
On Thu, Jan 23, 2014 at 8:03 AM, Paul Smith wrote: > add_library(mylib STATIC $) [snip] > The Makefile generators work fine > > For Xcode, though, the link fails: This is a known limitation. From the add_library documentation: http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:add_library "Some native build systems may not like targets that have only object files, so consider adding at least one real source file" -Brad -- 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://www.cmake.org/mailman/listinfo/cmake
[CMake] [2.8.12.1] Bug in Xcode generation of STATIC from OBJECT libraries
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 $) 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! -- 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://www.cmake.org/mailman/listinfo/cmake