CMake and Boost

DragonM

03-05-2010 03:21:13

I don't know if anybody else has this problem, but the MyGUI demos and Ogre Platform library won't build for me out of the box because they need to find and use Boost threads. For some reason Ogre wasn't statically linked to Boost. This is inconvenient when building out of MyGUI SVN, because it's updated so frequently. (For which we are all grateful and thankful. :D)

Here's a patch to include Boost in the build system:


Index: Dependencies.cmake
===================================================================
--- Dependencies.cmake (revision 2991)
+++ Dependencies.cmake (working copy)
@@ -75,6 +75,14 @@
find_package(OIS)
macro_log_feature(OIS_FOUND "OIS" "Input library needed for the samples" "http://sourceforge.net/projects/wgois" FALSE "" "")
endif()
+set(Boost_USE_STATIC_LIBS ON)
+set(Boost_USE_MULTITHREADED ON)
+find_package( Boost 1.42 COMPONENTS thread )
+if(Boost_FOUND)
+ set(BOOST_FOUND ${Boost_FOUND})
+endif()
+macro_log_feature(BOOST_FOUND "BOOST" "Threading library needed for OGRE"
+"http://www.boost.org" TRUE "" "")

#######################################################################
# Tools
Index: Utils/MyGUIConfigTargets.cmake
===================================================================
--- Utils/MyGUIConfigTargets.cmake (revision 2991)
+++ Utils/MyGUIConfigTargets.cmake (working copy)
@@ -97,6 +97,8 @@
${MYGUI_SOURCE_DIR}/Common
${MYGUI_SOURCE_DIR}/MyGUIEngine/include
)
+ include_directories(${Boost_INCLUDE_DIRS})
+ link_directories(${Boost_LIBRARY_DIRS})
# define the sources
include(${PROJECTNAME}.list)

@@ -159,6 +161,7 @@
target_link_libraries(${PROJECTNAME}
MyGUIEngine
Common
+ ${Boost_LIBRARIES}
)
if (APPLE)
find_library(CF_LIBRARY CoreFoundation)


The patch applies to SVN Revision 2991, and may apply to earlier or later versions successfully.
Save it as boost_integration.patch or such to the top level CMake directory in MyGUI SVN and use TortoiseSVN -> Apply Patch... to use it.

DM