Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
582 stars 342 forks source link

configure fails to find gtest: error: C++ versions less than C++14 are not supported. #1536

Closed yurivict closed 12 months ago

yurivict commented 12 months ago

Problem description

configure prints:

Checking for C++ header file gtest/gtest.h... no
Checking for C++ header file gmock/gmock.h... no
ERROR: Expected system installation of Googletest-1.8.0, but it could not be found.
See 'config.log' for details.

Corresponding lines in config.log:

++ -o .sconf_temp/conftest_b364a5a11a827ae1c960e92df52823d0_0_c72a797dad337bdbf47b3c8d599cb24f.o -c -std=c++11 -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -pthread -O3 -DNDEBUG -I/usr/local/include -I/usr/local/include/eigen3 .sconf_temp/conftest_b364a5a11a827ae1c960e92df52823d0_0.cpp
In file included from .sconf_temp/conftest_b364a5a11a827ae1c960e92df52823d0_0.cpp:2:
In file included from /usr/local/include/gmock/gmock.h:56:
In file included from /usr/local/include/gmock/gmock-actions.h:145:
In file included from /usr/local/include/gmock/internal/gmock-internal-utils.h:49:
In file included from /usr/local/include/gmock/internal/gmock-port.h:57:
/usr/local/include/gtest/internal/gtest-port.h:270:2: error: C++ versions less than C++14 are not supported.
#error C++ versions less than C++14 are not supported.
 ^

Steps to reproduce regular configure

Suggested solutions (1) Do not require googletest during build. The purpose of googletest is for testing, so if the users would like to run tests - they would be required to have googletest. (2) Use c++20. Now in 2023 virtually all compilers support c++20.

ischoegl commented 12 months ago

Moving to c++20 is unlikely as support for some older long-time supported OS’s is desirable. Regarding the other option, the gtest suite is essential to confirm that everything is working as expected, which appears to be especially important for packaging. Note that Cantera is now compiled with C++17, so there should not be an issue? To me, the error message about C++ 14 makes little sense (is this an upstream bug?); in case there are peculiarities of gtest-port compatibilities, PR’s would certainly be welcome.

PS: I had assumed that this was for the development version (main), but I just noticed that the flag std=c++11 was set, which will no longer work for the upcoming Cantera release regardless. If this is for an older version, please provide the information that the bug report template is asking for.

yurivict commented 12 months ago

The latest googletest fails with --std=c++11. You should change this to at least --std=c++14.

ischoegl commented 12 months ago

The latest googletest fails with --std=c++11. You should change this to at least --std=c++14.

I am not sure that I am following. Unless defaults are somehow overridden, all of Cantera is configured to use c++17 (including googletests, which you can see for the GH Action tests, e.g. https://github.com/Cantera/cantera/actions/runs/5476211997/jobs/9974847774).

scons: Configure: Checking for C++ header file gtest/gtest.h... 
.sconf_temp/conftest_56ec5a054fca65531fcaacd0904ff277_0.cpp <-
  |
  |#include "gtest/gtest.h"
  |
  |
g++ -o .sconf_temp/conftest_56ec5a054fca65531fcaacd0904ff277_0_27d2dbb2e9f27db465058811a3e62d19.o -c -isystem /usr/share/miniconda3/envs/test/include -std=c++17 -pthread -O3 -ffast-math -fno-finite-math-only -DNDEBUG .sconf_temp/conftest_56ec5a054fca65531fcaacd0904ff277_0.cpp
.sconf_temp/conftest_56ec5a054fca65531fcaacd0904ff277_0.cpp:2:10: fatal error: gtest/gtest.h: No such file or directory
    2 | #include "gtest/gtest.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
scons: Configure: no

(This is for a sundials runner on Ubuntu, which will use a private gtest installation)

yurivict commented 12 months ago

Version 2.6.0 has c++11 in SConstruct.

ischoegl commented 12 months ago

Ok. It would have helped if you had kept critical information we ask for in our bug report template:

**System information**

- Cantera version: [for example, 2.5.0 or the git commit hash]
- OS: [for example, Windows 10]
- Python/MATLAB/other software versions:

You should be able to disable the system gtest or skip it altogether by using the configuration option

googletest: [ 'default' | 'system' | 'submodule' | 'none' ] Select whether to use gtest/gmock from system installation (system), from a Git submodule (submodule), to decide automatically (default) or don't look for gtest/gmock (none) and don't run tests that depend on gtest/gmock.
default: 'default'

(See https://cantera.org/compiling/config-options.html#scons-config)

bryanwweber commented 12 months ago

I'm closing this. We're about to start beta for 3.0 which resolves this anyways and the option to disable googltest is clearly documented. Please feel free to reopen if there are other changes needed.