# Update cmake-compile-features(7) manual after deprecation of WriteCompilerDetectionHeader

**URL:** https://discourse.cmake.org/t/update-cmake-compile-features-7-manual-after-deprecation-of-writecompilerdetectionheader/3190
**Category:** Development
**Created:** [April 22, 2021, 6:27am UTC](https://discourse.cmake.org/t/update-cmake-compile-features-7-manual-after-deprecation-of-writecompilerdetectionheader/3190 "2021-04-22T06:27:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![petwu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petwu/32/1399_2.png) [@petwu](https://discourse.cmake.org/u/petwu)
#### Post date: [April 22, 2021, 6:27am UTC](https://discourse.cmake.org/t/update-cmake-compile-features-7-manual-after-deprecation-of-writecompilerdetectionheader/3190/1 "2021-04-22T06:27:15Z")

</div>

Hi, I noticed that in the recently released CMake v3.20 the [WriteCompilerDetectionHeader](https://cmake.org/cmake/help/v3.20/module/WriteCompilerDetectionHeader.html) module is now deprecated, but the [cmake-compile-features(7)](https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html) manual continues to recommend it for achieving feature depended implementations (section _Optional Compile Features_). The `write_compiler_detection_header()` command is used to generate a header with preprocessor defines that can be used for detecting features in the code.

Is suggest to remove the parts using `write_compiler_detection_header()` or at least warning about the deprecation and suggesting some alternative solutions instead. Those are the ones I could think about:

- **Generator Expressions**  
With the `COMPILE_FEATURES` generator expression the preprocessor define can easily be set manually:

- **CMAKE\_\<LANG\>\_COMPILE\_FEATURES**  
An alternative are variables like `CMAKE_CXX_COMPILE_FEATURES`, since they contain a list of all features the compiler supports.

@craig.scott, the same would apply to your book _Professional CMake: A Practical Guide_ (section 16.2.1 of the 8th edition).

---

<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: [April 22, 2021, 7:30am UTC](https://discourse.cmake.org/t/update-cmake-compile-features-7-manual-after-deprecation-of-writecompilerdetectionheader/3190/2 "2021-04-22T07:30:07Z")

</div>

Thanks @petwu, I’ve already updated the relevant parts in the upcoming 9th edition of the book.

@brad.king Since you were the most keen on the removal of the `WriteCompilerDetectionHeader` module, I’m assuming you had already formed a view on how projects should be updated to no longer use it. Not sure how you want to update the docs to reflect your alternative methods.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 22, 2021, 4:53pm UTC](https://discourse.cmake.org/t/update-cmake-compile-features-7-manual-after-deprecation-of-writecompilerdetectionheader/3190/3 "2021-04-22T16:53:37Z")

</div>

I’ve opened [CMake MR 6037](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6037) to update the `cmake-compile-features(7)` manual to account for the removal of WCDH.

The [policy CMP0120](https://cmake.org/cmake/help/latest/policy/CMP0120.html) documentation suggests alternatives to WCDH. The simplest solution, at least in the short term, is to run WCDH once by hand locally and then bundle the generated header with the project source.
