[CMake] cmake project patterns / examples

Chuck Atkins chuck.atkins at kitware.com
Tue Jun 3 15:56:40 EDT 2014


"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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140603/dd07c370/attachment.html>


More information about the CMake mailing list