]> SALOME platform Git repositories - tools/configuration.git/commitdiff
Salome HOME
Options to debug warnings EMC2P_V_1_3_0 V9_5_0b1
authorvsr <vsr@opencascade.com>
Thu, 23 Apr 2020 13:02:56 +0000 (16:02 +0300)
committervsr <vsr@opencascade.com>
Thu, 23 Apr 2020 13:02:56 +0000 (16:02 +0300)
cmake/SalomeSetupPlatform.cmake

index b1fd3a2d0e6134c18a2981d521720cb4750fa2d3..c470e35a1e778d7351b8a91687590af52add8b97 100644 (file)
@@ -48,16 +48,6 @@ ELSE()
   SET(PYLOGLEVEL WARNING)
 ENDIF()
 
-## Treat all warnings as errors
-IF(NOT (WIN32 OR APPLE))
-  OPTION(SALOME_DEBUG_WARNINGS "Treat warnings as errors" OFF)
-  MARK_AS_ADVANCED(SALOME_DEBUG_WARNINGS)
-  IF(SALOME_DEBUG_WARNINGS)
-    SET(CMAKE_C_FLAGS "-Werror")
-    SET(CMAKE_CXX_FLAGS "-Werror")
-  ENDIF()
-ENDIF()
-
 IF(WIN32)
   ## Windows specific:  
   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)  # To disable windows warnings for strcpy, fopen, ...
@@ -116,17 +106,37 @@ IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES)
   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names")
 ENDIF()
 
+SET(NO_CXX11_SUPPORT OFF CACHE BOOL "Disable C++11 support")
 IF(NOT NO_CXX11_SUPPORT)
   # C++11 support
   CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
   IF(COMPILER_SUPPORTS_CXX11)
     MESSAGE(STATUS "Enable C++11 support")
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-  ELSEIF(COMPILER_SUPPORTS_CXX0X)
-    MESSAGE(STATUS "Enable C++0x support")
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
   ELSE()
-    MESSAGE(WARNING "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    IF(COMPILER_SUPPORTS_CXX0X)
+      MESSAGE(STATUS "Enable C++0x support")
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    ELSE()
+      MESSAGE(WARNING "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
+    ENDIF()
+  ENDIF()
+ENDIF()
+
+# Fight warnings
+IF(NOT (WIN32 OR APPLE))
+  OPTION(SALOME_DEBUG_WARNINGS "Report more warnings" OFF)
+  OPTION(SALOME_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
+  # Report more warnings
+  MARK_AS_ADVANCED(SALOME_DEBUG_WARNINGS SALOME_TREAT_WARNINGS_AS_ERRORS)
+  IF(SALOME_DEBUG_WARNINGS)
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
+  ENDIF()
+  ## Treat all warnings as errors
+  IF(SALOME_TREAT_WARNINGS_AS_ERRORS)
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
   ENDIF()
 ENDIF()