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

David Cole david.cole at kitware.com
Tue Dec 22 06:50:32 EST 2009


On Tue, Dec 22, 2009 at 12:06 AM, Brian Davis <bitminer at gmail.com> wrote:

>
> I am continuing my attempt (latest in the saga) to use cmake to build 3rd
> third party libraries and integrate my code and hopefully build only what I
> need.
>
> <snip>



> There has been some conflicts adding in certain packages into this file
> (boost and vtk) with dcmtk.


> Am I in uncharted shark invested waters on a leaky inflatable raft covered
> in cheese bait, with what I am attempting or has anyone tried what I am
> trying to do.  Is this normal or just some form of crazy?
>
>
My investor friends would be pleased. They love sharks! I cannot say for
sure if you are coated with any yummy dairy products (after all, this is
just email) but, if you are using CMake, then you are most definitely in a
sound boat that will float for many years to come. I do understand things
can be overwhelming to start with, especially if you are trying to build
more than a few things... Rest assured, though, this particular form of
crazy is entirely normal.

You are correct: projects that are all intermingled together with
add_subdirectory calls in a parent project *can* interfere with each other,
especially if they do anything with "FORCE" and change variables to
"INTERNAL" to hide them from developers. And then there can simply be
unintended name clashes...

One way to overcome these things, but still build projects from source code
as needed is to use a new feature in CMake 2.8: the ExternalProject module.
There's a cmake function in there called "ExternalProject_Add" that allows
you to build another project as a separate entity so that its CMake settings
are still entirely independent of the settings in all the other projects
you're also building.

See "cmake --help-module ExternalProject_Add" -- and the test in the CMake
source tree at "CMake/Tests/ExternalProject" -- and the article I wrote
about this in Kitware's "The Source" newsletter: the October 2009 edition:
http://www.kitware.com/products/archive/kitware_quarterly1009.pdf (pp.
14-17)

Hopefully, this is helpful... Let me know if you have any questions about
using it.

:-)
David Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091222/a244cb4f/attachment.htm>


More information about the CMake mailing list