Re: [AMBER-Developers] Pmemd no longer compiling with older GCC (4.8.5)

From: Jamie Smith <jsmith.crackofdawn.onmicrosoft.com>
Date: Wed, 26 Jan 2022 05:20:19 +0000

Conveniently, CMake has built-in support for requiring a specific C/C++ language standard in a compiler-independent way.

We already set a requested C and CXX standard level here: https://gitlab.ambermd.org/amber/amber/-/blob/master/cmake/CompilationOptions.cmake#L49
All we need to do to make this mandatory is add these lines:

set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

This will cause CMake to error out if it determines the compiler in use does not support the requested standards. More details for those interested: https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html

Also, the code you pushed has the right idea but I would recommend wrapping it in a check for what compiler is actually in use. Something like this:

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
        message(FATAL_ERROR "Amber requires at least gcc-6.0")
    endif()
endif()

That way you can specify a different minimum version for each compiler.

Hope that makes sense,
    Jamie

-----Original Message-----
From: David A Case <david.case.rutgers.edu>
Sent: Tuesday, January 25, 2022 5:43 PM
To: AMBER Developers Mailing List <amber-developers.ambermd.org>
Subject: Re: [AMBER-Developers] Pmemd no longer compiling with older GCC (4.8.5)

On Tue, Jan 25, 2022, David Case wrote:

>Googling on "cmake minimum gnu version" shows how easy this is to
>implement
>there: cmake handles the hard part of even finding the GNU version --
>compare this to the 100+ lines of code in the old configure2 script to
>handle this task.

Update: I've pushed a new branch, minimum_compiler_check, that implements simple checks on g++ and gfortran. The error messages should be expanded to point users to documentation about how to fix the problem. And, the check on c++ might be changed to require a specific std-cxx version, but I don't immediately see how to implement that check right at the beginning of the cmake run, where it will do the most good.

Dan: can you try this branch on your 4.8.5 system? Think about how we might make the messages as easy as possible to understand.

...thx...dac


_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Tue Jan 25 2022 - 21:30:02 PST
Custom Search