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

Brian Davis bitminer at gmail.com
Tue Dec 22 11:29:07 EST 2009


<snip>

> > There will never be an easy way to pull external projects directly into a
>> > calling project because the external things are not even guaranteed to
>> be on
>> > disk yet at configure time of said calling project.
>>
>>
>> Yeah, kind of a chicken-egg problem...
>>
>
> Exactly. That's why we didn't try to solve that problem. If you have a
> chicken-egg problem to solve, you have to choose starting with a chicken or
> an egg, thereby alienating approximately 50% of your audience, even if you
> have good reasons for your choice.
>
<snip>

I like cake.  I like eating it too.  Mmmm cake!  Cmake may not *know where
the third party is when it configures*, but it *knows where it will be*.
The build will/could take care of the rest. Correct?  The 50% rule is how
Bush won the election (alienating half the audience - through Karl Rove
tactics)... we all know how that turned out :-) (this is a joke - and is
meant as such - don't read too much into it but has a half/50% serious part)

 <snip>

> So: there is one approach that's sort of a hybrid here, that I'll mention
> because it might be useful to consider.
>
> You could have a cmake option in your project that builds your project one
> of two ways: "as usual" or as the final link in a chain of
> ExternalProject_Add calls. I've done this and I know it works, but it's
> proprietary and I cannot point you to the source code. This technique,
> however, does make things hard to think about at times...
>
> Something like this in CMakeLists.txt:
> ==================================================
> option(MYPROJ_UBERBUILD "If ON, build all prereqs first, then build me..."
> ON)
> if(uberbuild)
>   include(BuildAllViaExternalProject.cmake)
> else()
>   include(BuildJustMe.cmake)
> endif()
>
> And as the last thing inside BuildAllViaExternalProject.cmake:
> ==================================================
> ExternalProject_Add(
>   DOWNLOAD_COMMAND ""
>   CMAKE_ARGS
>     -DMYPROJ_UBERBUILD:BOOL=OFF
>   SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
>   ...
> )
>
>
> The net effect is that a project can build itself as an ExternalProject
> with the "clever (?)" use of a CMake option....
>
> <snip>

Thank you,I will be looking into ExternalProject_Add and will keep this in
mind while creating my build tree.

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091222/705a74df/attachment.htm>


More information about the CMake mailing list