# How to find C11 threads

**URL:** <https://discourse.cmake.org/t/how-to-find-c11-threads/2506>\
**Category:** Code\
**Created:** [January 10, 2021, 9:54pm UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506 "2021-01-10T21:54:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wirtos](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wirtos/32/1081_2.png) [@Wirtos](https://discourse.cmake.org/u/Wirtos)\
**Post date:** [January 10, 2021, 9:54pm UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506/1 "2021-01-10T21:54:31Z")

</div>

I was trying to create a project involving the use of C11 threads, but I can’t find the requirements in the CMAKE\_C\_KNOWN\_FEATURES nor in the FindThreads package. Should I write custom detection code for this purpose, or did I miss something?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 11, 2021, 2:44pm UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506/2 "2021-01-11T14:44:44Z")

</div>

@robert.maynard Did we implement fine-grained features for C11 or is C11 a “all or nothing” detection?

---

<div class="post-metadata">

**Author:** ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)\
**Post date:** [January 11, 2021, 2:46pm UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506/3 "2021-01-11T14:46:54Z")

</div>

C11 has compile features, but as threads are part of the C standard library, and not a language feature they aren’t covered.

---

<div class="post-metadata">

**Author:** ![Wirtos](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wirtos/32/1081_2.png) [@Wirtos](https://discourse.cmake.org/u/Wirtos)\
**Post date:** [January 16, 2021, 11:57am UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506/4 "2021-01-16T11:57:59Z")

</div>

Sorry for the late reply, but threads are optional feature of the libc in C11, so they aren’t always present even if detected compiler is C11, the same goes for VLA and atomics, since C11 they’re optional features. For now I settled with custom output check against ` __STDC_NO_THREADS__ ` macro, but would like to see this feature requirement in cmake too

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [January 19, 2021, 7:40pm UTC](https://discourse.cmake.org/t/how-to-find-c11-threads/2506/5 "2021-01-19T19:40:37Z")

</div>

I don’t think that fine-grained library feature detection or flag manipulation is a game CMake should get into. We had enough trouble with language feature detection in the past that I don’t really want to see that Pandora’s Box opened again. I suppose that something could be added to `FindThreads`, but negative features aren’t really something that is easily modeled with CMake’s targets.

Personally, I would suggest another project which handles the compiler/library detection routine via a header and makes preprocessor definitions available based on version checks. This could then be maintained outside of CMake, updated independently, and used via `find_package` and/or `FetchContent`.
