[CMake] Build only what you need in third party libs

Michael Jackson mike.jackson at bluequartz.net
Mon Dec 7 14:09:06 EST 2009



On Dec 7, 2009, at 1:28 PM, troy d. straszheim wrote:

> Michael Jackson wrote:
>> So you are wanting to include the Boost sources in your project and  
>> you just want to build a specific subset of Boost to use with your  
>> project?
>
> Here's what I came up with:
>
> http://sodium.resophonic.com/boost-cmake/current-docs/exported_targets.html#with-boost-source-in-a-subdirectory-of-your-source
>
> the EXCLUDE_FROM_ALL option to add_subdirectory makes things  
> remarkably easy... nice feature.
>
> -t
>
>


Nice,
    Couple of comments though:
"Setting BUILD_PROJECTS, etc is unnecessary, but if all the extra  
boost targets bother you you can set it at the commandline as usual:"

Why can't I set BUILD_PROJECTS in my own CMakeLists.txt file? Wouldn't  
this get rid of the need to pass this on the command line? Also what  
about those running CMake-GUI? They don't have a command line to work  
from?

  By using the name of the target (boost_filesystem-mt-shared in your  
example), will CMake automatically "do the right thing" with respect  
to Debug and release libraries? Will building my project as a Debug  
pick up the Debug Boost libraries?

  I see this as having some issues? I now have to detect when someone  
wants a "Debug" build then set the "BOOST_ENABLE_DEBUG=ON" before  
calling the add_subdirectory(boost-src).

  I say all this without having tried any of this but it _is_  
intriguing me currently due to all the problems trying to get Boost  
built OS X and Windows without memory leaks, compile errors and, ya  
know, basic stuff like that. If I can have my own patched version of  
boost in my project this may save some serious head aches in the future.

Mike Jackson


More information about the CMake mailing list