mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-28 12:45:13 +00:00
cmake: tidy up adding C++11 compile flags
Two blocks of code were trying to do the same thing in different ways; standardise on one, and only add the compile flags if CMake won't do it itself (policy CMP0067).
This commit is contained in:
parent
74ab9e72ac
commit
4d325dcd7a
1 changed files with 4 additions and 10 deletions
|
@ -181,7 +181,10 @@ CMAKE_POP_CHECK_STATE()
|
||||||
# the CHECK_CXX_SOURCE_COMPILES function. See CMake issue #16456.
|
# the CHECK_CXX_SOURCE_COMPILES function. See CMake issue #16456.
|
||||||
# Ensure we do this after the FIND_PACKAGE calls which use C, and will error on a C++
|
# Ensure we do this after the FIND_PACKAGE calls which use C, and will error on a C++
|
||||||
# standards flag.
|
# standards flag.
|
||||||
|
# Also see https://github.com/fish-shell/fish-shell/issues/5865
|
||||||
|
IF(NOT POLICY CMP0067)
|
||||||
LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}")
|
LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
CHECK_CXX_SOURCE_COMPILES("
|
CHECK_CXX_SOURCE_COMPILES("
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -195,14 +198,6 @@ int main () {
|
||||||
|
|
||||||
FIND_PROGRAM(SED sed)
|
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("
|
CHECK_CXX_SOURCE_COMPILES("
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -214,4 +209,3 @@ LIBATOMIC_NOT_NEEDED)
|
||||||
IF (NOT LIBATOMIC_NOT_NEEDED)
|
IF (NOT LIBATOMIC_NOT_NEEDED)
|
||||||
SET(ATOMIC_LIBRARY "atomic")
|
SET(ATOMIC_LIBRARY "atomic")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
CMAKE_POP_CHECK_STATE()
|
|
||||||
|
|
Loading…
Reference in a new issue