Project

General

Profile

Task #1847

improve means to specify C++ std library in CMake

Added by Szilárd Páll almost 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
build system
Target version:
Difficulty:
uncategorized
Close

Description

The C++11 check suffers from a subtle issue which manifests in that once the test fails, even if compiler flags are provided e.g. to pass the right gcc path to icc (for a compatible libstdc++ to be picked up), the detection is not carried out again [Repro case shown below].

$ gcc --version | head -n1
gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]
cmake [...]
CMake Error at CMakeLists.txt:609 (message):
  This version of GROMACS requires C++11. [...]

$ cmake -DCMAKE_C_FLAGS=-gcc-name=/path/to/gcc -DCMAKE_CXX_FLAGS=-gcc-name=/path/to/gcc
CMake Error at CMakeLists.txt:609 (message):
  This version of GROMACS requires C++11. [...]

The issue is likely more general and manifests with clang too.

Because it is likely too cumbersome to reset the detection results based on the CXX flags variable's content, we should consider introducing a separate variable in which the necessary information can be passed (and value of which can be used to re-trigger detection).

History

#1 Updated by Szilárd Páll almost 3 years ago

Any idea if this is till an issue?

#2 Updated by Mark Abraham almost 3 years ago

Szilárd Páll wrote:

Any idea if this is till an issue?

As written, no, because I re-wrote the machinery to separate compiler test from library test. The things mentioned here only apply to the latter.

To make it convenient to recover from getting the gcc wrong (including by not specifying one), we would have to add support via gmx_check_if_changed to unset cxx11_stdlib_present if the relevant user-supplied cache variables have changed, since the implementation of check_cxx_source_compiles is not aware of changes to cmake_required_flags, etc. into which the user-supplied values are put for the compilation test. That's a "convenience" fix that we could consider for release-2016.

#3 Updated by Mark Abraham over 1 year ago

  • Assignee set to Mark Abraham
  • Target version changed from future to 2018

There is some partial support for this (maybe added since this issue was filed?). See usage of GMX_STDLIB_CXX_FLAGS in docs/install-guide/index.rst which may (be able to) resolve this for icc. clang probably needs further work. Test and reconsider before 2018 release

#4 Updated by Mark Abraham over 1 year ago

  • Status changed from New to Resolved

Things work with clang, icc, and are documented in the install guide. Reopen if there's a concrete issue.

#5 Updated by Erik Lindahl over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF