# Selecting quality CMake code example(s)

**URL:** https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289
**Category:** Code
**Created:** [August 17, 2022, 8:48am UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289 "2022-08-17T08:48:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![EricGT](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@EricGT](https://discourse.cmake.org/u/EricGT)
#### Post date: [August 17, 2022, 8:48am UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289/1 "2022-08-17T08:48:04Z")

</div>

In a [related](https://discourse.cmake.org/t/looking-for-complete-examples-of-cross-platform-projects/4731) question a suggestion was made to create list of quality CMake code examples.

One GitHub repository that while large seems to meet the criteria is

> **[GitHub - qt/qtbase: Qt Base (Core, Gui, Widgets, Network, ...)](https://github.com/qt/qtbase)**
>
> Qt Base (Core, Gui, Widgets, Network, ...). Contribute to qt/qtbase development by creating an account on GitHub.

GitHub [query](https://github.com/search?l=CMake&p=1&q=repo%3Aqt%2Fqtbase+filename%3A%2Acmake%2A+language%3ACMake&ref=advsearch&type=Code) for just the CMake code.

As I am new to using CMake, still working through the [tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/index.html), can others here weight in on if this repo is using quality CMake code so that I can include it in my list.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [August 17, 2022, 2:13pm UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289/2 "2022-08-17T14:13:48Z")

</div>

Qt does some pretty advanced, complex and unconventional things. Some of that has to do with its desire to support things that qmake did, others are a consequence of its plugin architecture and the desire to automate various things for the developer. I wouldn’t generally recommend it as a tutorial sample, if for no other reason than the significant complexity.

---

<div class="post-metadata">

### Author: ![EricGT](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@EricGT](https://discourse.cmake.org/u/EricGT)
#### Post date: [August 17, 2022, 2:28pm UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289/3 "2022-08-17T14:28:21Z")

</div>

> [@craig.scott](#):
>
> I wouldn’t generally recommend it as a tutorial sample

Thanks.

I am not necessarily looking for a tutorial example but code that does it correctly, period.

In learning CMake I am coming to understand that finding things is an important part and qt/qtbase seems to have a lot of that.

> [@craig.scott](#):
>
> Some of that has to do with its desire to support things that [qmake](https://doc.qt.io/qt-6/qmake-manual.html) did

Did not know that Qt had its own make tool, but then never programmed in Qt. Will take into consideration when looking at their code.

* * *

On a side note, learned a lot from

[Deep CMake for Library Authors](https://www.youtube.com/watch?v=m0DwB4OvDXk) - Craig Scott - CppCon 2019

and like the _Recommended Practices_ in your book, “Professional CMake A Practical Guide” 🙂

---

<div class="post-metadata">

### Author: ![Mathieu\_Westphal](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathieu_westphal/32/133_2.png) [@Mathieu\_Westphal](https://discourse.cmake.org/u/Mathieu_Westphal)
#### Post date: [August 29, 2022, 1:57am UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289/4 "2022-08-29T01:57:52Z")

</div>

I have a project of relative small size and (I hope) good CMake quality. I hope it helps:

> **[GitHub - f3d-app/f3d: A fast and minimalist 3D viewer.](https://github.com/f3d-app/f3d)**
>
> A fast and minimalist 3D viewer. Contribute to f3d-app/f3d development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![EricGT](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@EricGT](https://discourse.cmake.org/u/EricGT)
#### Post date: [September 8, 2022, 7:55am UTC](https://discourse.cmake.org/t/selecting-quality-cmake-code-example-s/6289/5 "2022-09-08T07:55:39Z")

</div>

Is [PCRE2](https://github.com/PCRE2Project/pcre2) (Perl-Compatible Regular Expressions) an example of quality CMake code?

[CMakeLists.txt](https://github.com/PCRE2Project/pcre2/blob/master/CMakeLists.txt)  
[CMake](https://github.com/PCRE2Project/pcre2/tree/master/cmake) directory
