summaryrefslogtreecommitdiffhomepage
path: root/cmake/mingw-w64.cmake
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-05-13 12:51:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-05-13 12:51:40 +0200
commit41a92ea7401c89c5696b3e1b2fa239458a92ff73 (patch)
treed39c1b36aae1bd0c15690a96464992607f3a5e42 /cmake/mingw-w64.cmake
parent5706c16245e809ea712f6b685389e072bcca19a4 (diff)
cmake: add cache variables for predefined warning types
The numeric warnings are somewhat useful. Sadly only clang supports the vtable object file bloat warning.
Diffstat (limited to 'cmake/mingw-w64.cmake')
-rwxr-xr-xcmake/mingw-w64.cmake36
1 files changed, 34 insertions, 2 deletions
diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake
index 9adfa907..7d3db429 100755
--- a/cmake/mingw-w64.cmake
+++ b/cmake/mingw-w64.cmake
@@ -44,10 +44,42 @@ set(_LDFLAGS " -Wl,--as-needed ${_CXXFLAGS} ")
set(_LDFLAGS_RELEASE " ${_CXXFLAGS_RELEASE} ")
set(_LDFLAGS_DEBUG " ${_CXXFLAGS_DEBUG} ")
+set(WARNINGS_ENABLE TRUE CACHE BOOL "Emit additional warnings at compile-time")
+# these are very noisy, high false positive rate. only for development.
+set(WARNINGS_FINAL_SUGGESTIONS FALSE CACHE BOOL "Emit very noisy warnings at compile-time")
+set(WARNINGS_PEDANTIC FALSE CACHE BOOL "Emit very noisy warnings at compile-time")
+set(WARNINGS_NUMERIC FALSE CACHE BOOL "Emit very noisy warnings at compile-time")
+
+set(noisy-warns "")
+set(suggest-final "")
+set(pedantics "")
+set(numerics "")
+if(CMAKE_PROJECT_NAME STREQUAL "opentrack" AND WARNINGS_ENABLE)
+ if(WARNINGS_FINAL_SUGGESTIONS)
+ set(suggest-final "-Wsuggest-final-types -Wsuggest-final-methods")
+ endif()
+ if(WARNINGS_PEDANTIC)
+ set(pedantics "-Wuseless-cast -Wsuggest-override")
+ endif()
+ if(WARNINGS_NUMERIC)
+ set(numerics "-Wdouble-promotion")
+ endif()
+ set(noisy-warns "${suggest-final} ${pedantics} ${numerics}")
+endif()
+
+# -Wodr and -Wattributes are disabled due to LTO false positives in dependencies.
+set(clang-warns "")
+if(CMAKE_COMPILER_IS_CLANG)
+ set(clang-warns "-Wweak-vtables")
+endif()
+set(_CXX_WARNS "")
+if(WARNINGS_ENABLE)
+ set(_CXX_WARNS "-Wall -Wextra -pedantic -Wdelete-non-virtual-dtor -Wsign-compare -Wno-odr -Wno-attributes -Wcast-align -Wc++14-compat ${clang-warns} ${noisy-warns}")
+endif()
+
foreach(j C CXX)
foreach(i "" _DEBUG _RELEASE)
- set(OVERRIDE_${j}_FLAGS${i} "" CACHE STRING "")
- set(CMAKE_${j}_FLAGS${i} " ${_${j}FLAGS${i}} ${OVERRIDE_${j}_FLAGS${i}} " CACHE STRING "" FORCE)
+ set(CMAKE_${j}_FLAGS${i} " ${_${j}FLAGS${i}} ${_${j}_WARNS} ${OVERRIDE_${j}_FLAGS${i}} " CACHE STRING "" FORCE)
endforeach()
endforeach()