On Thu, 2014-01-23 at 10:22 -0500, Brad King wrote:
> On Thu, Jan 23, 2014 at 8:03 AM, Paul Smith <p...@mad-scientist.net> wrote:
> >   add_library(mylib STATIC $<TARGET_OBJECTS:mylib_OBJECTS>)
> [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 $<TARGET_OBJECTS:${LIB}_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

Reply via email to