[Bug]: cmake configuration broken for compilers without C++14
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Describe the issue
**prologue:**
yes this sounds strange at first, since C++14 is the minimum for the project. But here are the details.
**description:**
GTEST needs minimum C++14 to be compiled
It can therefore be also compiled with C++14 or higher.
higher also means C++17. [proof of packages in C++17 @ conancenter](https://conan.io/center/recipes/gtest)
As a result if your compiler supports C++17 gtest should be in theory usable.
There are some more special compilers out there not supporting C++14, but C++17. (one example is IAR)
when configuring cmake with such a compiler we fail. (configure step of cmake! not build step!)
**technical details:**
in the file [googletest/googletest/cmake/internal_utils.cmake in line 198](https://github.com/google/googletest/blob/504ea69cf7e9947be54f808a09b7b08988e84b5f/googletest/cmake/internal_utils.cmake#L198C3-L198C53)
there is following line of code
```
target_compile_features(${name} PUBLIC cxx_std_14)
```
This sets a requirement, that the compiler, used for the specified files, supports specific compiler features. [CMake Docu Link](https://cmake.org/cmake/help/latest/command/target_compile_features.html)
`cxx_std_14` means the compiler supports C++14.
That's true for most compilers using C++17 (gcc, clang etc) but not for all.
`cxx_std_17` can also be enough for C++17 compiles. [CMake Docu Link](https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#high-level-meta-features-indicating-c-standard-support)
**possible solutions**
1. Move the check to another place
2. specify feature based on `CXX_STANDARD` [CMake Docu Link](https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html)
3. remove this check
### Steps to reproduce the problem
cmake-configure gtest with iar (or any other compiler supporting `cxx_std_17`, but not `cxx_std_14`)
### What version of GoogleTest are you using?
1.15.0
### What operating system and version are you using?
* ubuntu 24.04.1
* ubuntu 24.04 in docker
### What compiler and version are you using?
IAR
### What build system are you using?
CMake
### Additional context
**details on IAR CMake Module**
`cxx_std_17` is set by the IAR CMake module
**CMake Documentation**
The Documentation on the flags is a bit ambiguous. [LINK](https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#high-level-meta-features-indicating-c-standard-support)
> The following meta features indicate general support for the associated language standard. It reflects the language support claimed by the compiler, [...]
My interpretation: if feature is set, we support this explicit standard, here C++14
>cxx_std_14
>Compiler mode is at least C++ 14.
What does "at least" mean here?
* till C++14?
* C++14 and higher?
* C++14 and maybe others, based on other featureflags?
the last interpretation makes the most sense to me. But can still be misunderstanded.
Contributor guide
Assessment
This issue has not been assessed yet.