]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: use CMAKE_CXX_STANDARD for enabling C++11 10279/head
authorKefu Chai <kchai@redhat.com>
Wed, 13 Jul 2016 09:43:12 +0000 (17:43 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 13 Jul 2016 11:50:33 +0000 (19:50 +0800)
hope we can drop the crufts when moving to cmake 3.1+

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt
src/test/CMakeLists.txt

index 429af422524fa6024ebedc97b8468f0e124dbff9..42382b6be1b69a500f088268fd979d26a071d048 100644 (file)
@@ -98,15 +98,19 @@ endif(no_yasm)
 set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -ftemplate-depth-1024 -Wno-invalid-offsetof -Wnon-virtual-dtor -Wno-invalid-offsetof -Wstrict-null-sentinel -Woverloaded-virtual")
 
 # require c++11
-include(CheckCXXCompilerFlag)
-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-if (COMPILER_SUPPORTS_CXX11)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+if(CMAKE_VERSION VERSION_LESS "3.1")
+  include(CheckCXXCompilerFlag)
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  if(COMPILER_SUPPORTS_CXX11)
+    list(APPEND CMAKE_CXX_FLAGS -std=c++11)
+  else()
+    message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+  endif()
 else()
-  message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+  set(CMAKE_CXX_STANDARD 11)
+  set(CMAKE_CXX_EXTENSIONS OFF)
 endif()
 
-
 ## Handle diagnostics color if compiler supports them.
 
 CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always"
index f8b50aa40c0a1bd9d792179353e64f585147aacf..8e065aa156f606de69a59745740e9d52e13a8814 100644 (file)
@@ -357,7 +357,7 @@ add_executable(ceph_perf_local
   perf_local.cc
   perf_helper.cc)
 #INTEL_SSE & INTEL_SSE2 flags
-set(PERF_LOCAL_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2") 
+set(PERF_LOCAL_FLAGS "-msse -msse2")
 set_target_properties(ceph_perf_local PROPERTIES COMPILE_FLAGS
   ${PERF_LOCAL_FLAGS})
 target_link_libraries(ceph_perf_local os global ${UNITTEST_LIBS})