Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: cmake configuration broken for compilers without C++14 #4697

Open
Sickeroni opened this issue Jan 15, 2025 · 0 comments
Open

[Bug]: cmake configuration broken for compilers without C++14 #4697

Sickeroni opened this issue Jan 15, 2025 · 0 comments

Comments

@Sickeroni
Copy link

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
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
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
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

possible solutions

  1. Move the check to another place
  2. specify feature based on CXX_STANDARD CMake Docu Link
  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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant