Skip to content

Commit

Permalink
cmake: force C++11 in CHECK_CXX_SOURCE_COMPILES for atomic
Browse files Browse the repository at this point in the history
GCC 4.8 requires the use of `-std=gnu++11` or similar to enable atomic
features. However, older versions of CMake don't pick up the
project-wide target for C++11 when building the configure check targets.
Although CMake policy 0067 could be set to NEW to enable this, it only
exists on CMake 3.8 and newer, while many of our supported platforms are
on an older version.
  • Loading branch information
zanchey committed Dec 21, 2019
1 parent 6dd9e50 commit 45633f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmake/ConfigureChecks.cmake
Expand Up @@ -189,6 +189,13 @@ int main () {
FIND_PROGRAM(SED sed)

# https://github.com/fish-shell/fish-shell/issues/5865
CMAKE_PUSH_CHECK_STATE()
# Needed until CMP0067 is set to NEW
# g++ 4.8 needs -std=gnu+11 set to enable atomic features, but CMake < 3.8 does not add that
# flag to TRY_COMPILE targets even when set for the project
IF(CMAKE_COMPILER_IS_GNUCXX)
LIST(APPEND CMAKE_REQUIRED_FLAGS "-std=gnu++11")
ENDIF()
CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
#include <cstdint>
Expand All @@ -200,3 +207,4 @@ LIBATOMIC_NOT_NEEDED)
IF (NOT LIBATOMIC_NOT_NEEDED)
SET(ATOMIC_LIBRARY "atomic")
ENDIF()
CMAKE_POP_CHECK_STATE()

0 comments on commit 45633f4

Please sign in to comment.