cmake
config_error
ai_generated
partial
CMake Error: Feature cxx_std_98 is not available. Check that the compiler supports CXX_STANDARD 98.
ID: cmake/unknown-feature-cxx-std-98
85%Fix Rate
85%Confidence
1Evidence
2023-06-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| CMake 3.27 | active | — | — | — |
| CMake 3.28 | active | — | — | — |
| CMake 3.29 | active | — | — | — |
Root Cause
CMake 3.1+ removed support for C++98 as a compile feature, so setting CMAKE_CXX_STANDARD to 98 or using cxx_std_98 in target_compile_features causes an error.
generic中文
CMake 3.1 及以上版本移除了对 C++98 作为编译特性的支持,因此将 CMAKE_CXX_STANDARD 设置为 98 或在 target_compile_features 中使用 cxx_std_98 会导致错误。
Official Documentation
https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.htmlWorkarounds
-
85% success set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)
-
70% success cmake -version # check current version # Install CMake 3.0 from https://cmake.org/files/v3.0/
cmake -version # check current version # Install CMake 3.0 from https://cmake.org/files/v3.0/
中文步骤
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)
cmake -version # check current version # Install CMake 3.0 from https://cmake.org/files/v3.0/
Dead Ends
Common approaches that don't work:
-
90% fail
CMake still validates the feature set; setting REQUIRED to OFF only makes it non-fatal but the feature is still unavailable, leading to silent build failures.
-
100% fail
The feature is hardcoded in CMake's internal compiler detection; custom definitions cannot override it.