CMake: optimize checking for C++11/C++0x compiler support 78/38878/1
authorRafal Krypa <r.krypa@samsung.com>
Wed, 29 Apr 2015 15:16:54 +0000 (17:16 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Wed, 29 Apr 2015 15:22:40 +0000 (17:22 +0200)
Check for C++0x only when test for C++11 failed

Change-Id: Ia02f110a59e2d063bcd48957a1cc59d75279969c
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
CMakeLists.txt

index 93438f6..9ba14ae 100644 (file)
@@ -71,13 +71,15 @@ SET(CMAKE_CXX_FLAGS_CCOV       "-O2 -g --coverage")
 
 # Check for C++11 support and enable proper compilation flags
 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
 IF(COMPILER_SUPPORTS_CXX11)
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-ELSEIF(COMPILER_SUPPORTS_CXX0X)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
 ELSE()
-    MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    IF(COMPILER_SUPPORTS_CXX0X)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    ELSE()
+        MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+    ENDIF()
 ENDIF()
 
 # Set compiler warning flags