[CMake] Cmake: Link boost statically in Xcode

Matthias Dörfelt hi at mokafolio.de
Mon Nov 21 16:39:23 EST 2011


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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111121/26fcd30a/attachment.htm>


More information about the CMake mailing list