[CMake] cmake project patterns / examples

Adam adam707blue at gmail.com
Wed Jun 4 01:23:07 EDT 2014


Thanks for the comments I've update the wiki. Top-level only now marked as
anti-pattern
https://github.com/toomuchatonce/cmake-examples/wiki/cmake-patterns-and-examples

If there are other patterns / anti-patterns you've seen please send me a
pull request and I'll add them.

I'm particularly interested in super-build patterns that allow sub-projects
(for both inhouse and 3rdparty components) to be shared between projects.





On Wed, Jun 4, 2014 at 5:56 AM, Chuck Atkins <chuck.atkins at kitware.com>
wrote:

> "Just put all the build commands in the top level cmake file."
>
> Definitely an anti-pattern.  As you mentioned, it definitely doesn't
> scale.  The problem with even doing this for a simple project is that it
> builds this behavior for people trying to learn cmake through simple
> examples.  This very very quickly turns in to a 3k line top level
> CMakeLists.txt  for even moderately sized projects.  I would really
> discourage this one as "don't do it ever" because of the bad behaviours it
> builds early on.
>
> - Chuck
>
> On Tue, Jun 3, 2014 at 1:22 PM, Iosif Neitzke <
> iosif.neitzke+cmake at gmail.com> wrote:
>
>> Great to see these examples with pros and cons.
>>
>> I believe the staticlibs-include example [0] pattern, though mentioned
>> in Mastering CMake [1], generally is deprecated in favor of
>> add_subdirectory with CMakeLists.txt at each level for self-contained
>> projects.
>>
>> [0]
>> https://github.com/toomuchatonce/cmake-examples/tree/master/staticlibs-include
>>
>> [1] Mastering CMake, 6th Edition, Chapter 7: Converting Existing
>> Systems to CMake, Source Code Directory Structures, page 116
>>
>> On Mon, Jun 2, 2014 at 5:23 PM, Adam Boseley <adam707blue at gmail.com>
>> wrote:
>> >
>> > There's a lot of legacy examples around the web but not too many using
>> the
>> > newer features.  What is the current best practise?
>> >
>> > Here's some simple examples
>> >
>> https://github.com/toomuchatonce/cmake-examples/wiki/cmake-patterns-and-examples
>> >
>> > Are these patterns or anti-patterns?
>> >
>> > Regards,
>> > Adam
>> >
>> > --
>> >
>> > Powered by www.kitware.com
>> >
>> > Please keep messages on-topic and check the CMake FAQ at:
>> > http://www.cmake.org/Wiki/CMake_FAQ
>> >
>> > Kitware offers various services to support the CMake community. For more
>> > information on each offering, please visit:
>> >
>> > CMake Support: http://cmake.org/cmake/help/support.html
>> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> > CMake Training Courses: http://cmake.org/cmake/help/training.html
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.cmake.org/mailman/listinfo/cmake
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140604/91f376f6/attachment-0001.html>


More information about the CMake mailing list