[CMake] Cmake: Link boost statically in Xcode

David Cole david.cole at kitware.com
Mon Nov 21 18:20:29 EST 2011


If you are building a static library, then there is nothing for the
linker to put into your library that comes from boost.

If somebody then builds a shared library or an executable that links
to your library, they will also have to link the dependent boost
libraries, if the functions they call in your library actually need
some of the functions from the boost libraries...

That's just the way static libs work.


HTH,
David


2011/11/21 Matthias Dörfelt <hi at mokafolio.de>:
> Hi,
> I am new to Xcode and I am currently trying to replicate existing Xcode
> projects (i manually created) with CMake for future portability reasons.
> Anyways, I am experiencing some weirdness when trying to build a static
> library using the Xcode generator. Here is an excerpt of the CMake script:
> #find boost
> set(Boost_USE_STATIC_LIBS ON)
> find_package(Boost COMPONENTS system thread chrono REQUIRED)
> include_directories( ${Boost_INCLUDE_DIR} )
> link_directories(${Boost_LIBRARY_DIRS})
> #add other things...
> add_library(MotorCore STATIC ${sources})
> target_link_libraries(MotorCore ${Boost_LIBRARIES})
> Boost is found, the static library libMotorCore.a builds fine in Xcode. What
> makes me wondering though is that there is no hint inside Xcode about the
> linking with boost system, thread or chrono. Neither in the library search
> paths, nor in a Link Binary with Libraries build phase. Now if I add the
> libMotorCore.a to another project i get lots of linker errors related to
> boost. if I manually add a Link Binary with Libraries  build phase in the
> CMake generated Xcode project, things work as expected, and boost gets
> properly linked. Am I doing something wrong?
> Is there any way to link libraries in CMake that works like Xcode's Link
> Binary with Libraries build phase?
> Thanks for your time!
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list