Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikekasprzak/requirecxxfeature
Simple cmake module to specify required C++ and standard library features
https://github.com/mikekasprzak/requirecxxfeature
cmake cmake-modules cplusplus cplusplus-20 cpp
Last synced: 2 months ago
JSON representation
Simple cmake module to specify required C++ and standard library features
- Host: GitHub
- URL: https://github.com/mikekasprzak/requirecxxfeature
- Owner: mikekasprzak
- License: mit
- Created: 2024-07-13T14:53:28.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-13T15:20:42.000Z (7 months ago)
- Last Synced: 2024-10-20T08:13:20.956Z (3 months ago)
- Topics: cmake, cmake-modules, cplusplus, cplusplus-20, cpp
- Language: CMake
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RequireCXXFeature
A set of cmake modules for specifing required C++ and C++ standard library features. It works by checking for
C++20 feature test macros. It builds on the built-in `CheckCXXSymbolExists` cmake module by providing a simpler syntax.## Usage
Add the `.cmake` files to your project, then include and use them.### CMakeFiles.txt
```cmake
...include (RequireCXXFeature.cmake)
# Reference: https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#table-of-feature-test-macros# Required C++ features
require_cxx_feature(__cpp_constexpr)
require_cxx_feature(__cpp_decltype_auto)
require_cxx_feature(__cpp_lib_coroutine)
require_cxx_feature(__cpp_lib_format)```
## Polyfilling a C++ feature with CheckCXXFeature
Instead of raising an error, `CheckCXXFeature` sets a variable if the requested C++ feature flag is found.```cmake
...include (CheckCXXFeature.cmake)
include (RequireCXXFeature.cmake)
# Reference: https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#table-of-feature-test-macros# Required C++ features
require_cxx_feature(__cpp_constexpr)
require_cxx_feature(__cpp_decltype_auto)
require_cxx_feature(__cpp_lib_coroutine)
check_cxx_feature(__cpp_lib_format HAS_LIB_FORMAT)
if (NOT DEFINED "${HAS_LIB_FORMAT}")
# polyfill config goes here
endif()
```