[CMAKE] Disable debugging related GCC flags in release mode.
[reactos.git] / reactos / cmake / gcc.cmake
index 7b7bb5d..64b0d33 100644 (file)
@@ -12,7 +12,9 @@ if(NOT DEFINED SEPARATE_DBG)
 endif()
 
 # Dwarf based builds (no rsym)
-if(NOT DEFINED NO_ROSSYM)
+if(CMAKE_BUILD_TYPE STREQUAL "Release")
+    set(NO_ROSSYM TRUE)
+elseif(NOT DEFINED NO_ROSSYM)
     set(NO_ROSSYM FALSE)
 endif()
 
@@ -38,6 +40,10 @@ endif()
 
 # Compiler Core
 add_compile_flags("-pipe -fms-extensions -fno-strict-aliasing")
+
+# Prevent GCC from searching any of the default directories
+add_compile_flags("-nostdinc")
+
 if(GCC_VERSION VERSION_GREATER 4.7)
     add_compile_flags("-mstackrealign")
 endif()
@@ -81,12 +87,14 @@ if((NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT SEPARATE_DBG))
 endif()
 
 # Debugging
-if(SEPARATE_DBG)
-    add_compile_flags("-gdwarf-2 -ggdb")
-else()
-    add_compile_flags("-gdwarf-2 -gstrict-dwarf")
-    if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
-        add_compile_flags("-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols")
+if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
+    if(SEPARATE_DBG)
+        add_compile_flags("-gdwarf-2 -ggdb")
+    else()
+        add_compile_flags("-gdwarf-2 -gstrict-dwarf")
+        if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
+            add_compile_flags("-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols")
+        endif()
     endif()
 endif()
 
@@ -112,11 +120,8 @@ add_compile_flags("-Wno-char-subscripts -Wno-multichar -Wno-unused-value")
 
 if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
     add_compile_flags("-Wno-maybe-uninitialized")
-    add_compile_flags("-Wno-error=unused-but-set-variable")
 endif()
 
-add_compile_flags("-Wno-error=type-limits")
-
 if(ARCH STREQUAL "amd64")
     add_compile_flags("-Wno-format")
 elseif(ARCH STREQUAL "arm")
@@ -423,7 +428,8 @@ function(CreateBootSectorTarget _target_name _asm_file _binary_file _base_addres
 endfunction()
 
 function(allow_warnings __module)
-    add_target_compile_flags(${__module} "-Wno-error")
+    # We don't allow warnings in trunk, this needs to be reworked. See CORE-6959.
+    #add_target_compile_flags(${__module} "-Wno-error")
 endfunction()
 
 macro(add_asm_files _target)