summaryrefslogtreecommitdiffstats
path: root/SetFlags.cmake
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-09 12:02:58 +0200
committerMattes D <github@xoft.cz>2014-10-09 12:02:58 +0200
commit386068a5adb3968030daa52d48fed16191c5cefa (patch)
tree079e7c5a75a02118171b6240e413584799fbdbdd /SetFlags.cmake
parentMerge pull request #1519 from mc-server/submodulize (diff)
parentFix flag name in gcc 4.6 and earlier (diff)
downloadcuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar.gz
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar.bz2
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar.lz
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar.xz
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.tar.zst
cuberite-386068a5adb3968030daa52d48fed16191c5cefa.zip
Diffstat (limited to '')
-rw-r--r--SetFlags.cmake30
1 files changed, 26 insertions, 4 deletions
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 1827a4b66..c0a021c25 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -59,12 +59,25 @@ macro(set_flags)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
elseif(APPLE)
- #on os x clang adds pthread for us but we need to add it for gcc
- if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ endif()
+
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND (NOT GCC_VERSION VERSION_GREATER 4.6))
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++0x")
+ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
+ endif()
+ #on os x clang adds pthread for us but we need to add it for gcc
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_flags_cxx("-stdlib=libc++")
add_flags_lnk("-stdlib=libc++")
else()
@@ -77,8 +90,17 @@ macro(set_flags)
add_flags_cxx("-pthread")
endif()
- # Make CLang use C++11, otherwise MSVC2008-supported extensions don't work ("override" keyword etc.):
- if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ endif()
+
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND (NOT GCC_VERSION VERSION_GREATER 4.6))
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++0x")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++0x")
+ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -std=c++11")