Facilitate linking with libcxx
Using recent clang static analyzer versions seems to be easier with
libcxx, which we should anyway support for building and testing.
Reworked the testing for C++11 support, since it is sensible to first
test the compiler, and then the standard library. This helps users
diagnose problems. Converted this code to a function (for better
scoping), added some docs, and made the semantics clearer. Added
some explicit testing for other non-library C++11 functionality.
Introduced GMX_STDLIB_CXX_FLAGS, so that all the linked executables
can have their sources compiled with any compiler flag that might be
required. Alternatives like requiring the user to modify
CMAKE_CXX_FLAGS, or adding COMPILE_FLAGS properties to targets didn't
seem great. The latter also triggers clang to issue warnings for
source files that are still C (group kernels and TNG).
Introduced GMX_STDLIB_LIBRARIES, so that linking can proceed
correctly.
For example, the check for C++11 support needs to be passed a library
to link during the try_compile(), and the only reliable way for the
user to do that before this patch was to add the linker flag to
CMAKE_CXX_FLAGS, which then leads to clang warning about the unused
linker flag as it compiles each source file. The GMX_STDLIB_*
mechanisms probably also permit users to build against different
versions of GNU libstdc++, which may be useful on distributions like
CentOS, because CMake has no mechanism at all for this.
Updated the install guide to clarify how to choose a standard library
in the various cases. Updated the guide for using GROMACS as a library,
and the template README.
Fixed issue where the template did not have C++11 compiler flags
propagated properly. The template now builds correctly, via both
Makefile.pkg and cmake, both with normal default libstdc++ and libc++
selected via this mechanism and propagated to the installed build
system for the template.
Fixed issue where SIMD suggestion would produce a garbage suggestion
when the linking failed and OUTPUT_SIMD was left unset.
Refs #1745,#1790
Change-Id: Ieef3b47de5c1a00a203baa1b34ebf70535cf5ff0
15 files changed: