-# ... and for Clang
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3")
- message(FATAL_ERROR "Your compiler is too old; you need Clang 3.3+, GCC 4.8+, MSVC 19.0+, or any other compiler with full C++11 support.")
- endif()
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -Wno-deprecated-register")
- # set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") # Use CMake default
- # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG") # Use CMake default
- set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-inline")
-
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing")
-
-# For MSVC, at least do a version sanity check...
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0")
- message(FATAL_ERROR "Your compiler is too old; you need at least Visual Studio 2015 (MSVC 19.0+), GCC 4.8+, Clang 3.3+, or any other compiler with full C++11 support.")
- endif()
+# For GCC and Clang, enable a whole bunch of warnings
+if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ add_compile_options(
+ -Wall
+ -Wcast-align
+ -Wextra
+ -Wformat-security
+ -Wno-unknown-pragmas
+ -Wnon-virtual-dtor
+ -Wpedantic
+ -Wundef
+ -fno-common
+ -fstack-protector-strong
+ "$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2>"
+ )