From 44d6dac407d8dc158468fba33dd4b92e7d734d32 Mon Sep 17 00:00:00 2001
From: Gabriel Ravier <gabravier@gmail.com>
Date: Sun, 27 Oct 2019 20:42:19 +0100
Subject: [PATCH 1/5] First attempt at making warnings work

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
---
 CMakeLists.txt       | 86 ++++++++++++++++++++++++++++++++++++++++++++
 Makefile             | 17 +++++++++
 README.md            |  6 ++++
 bin2h/CMakeLists.txt | 81 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f32d235a..107e0cef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,12 +9,39 @@ set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
 
 option(JAPANESE "Enable the Japanese-language build" OFF)
 option(FIX_BUGS "Fix various bugs in the game" OFF)
+option(WARNINGS "Enable common warnings" OFF)
+option(ALL_WARNINGS "Enable ALL warnings (clang/MSVC-only)" OFF)
+option(FATAL_WARNINGS "Stop compilation on any warnings" OFF)
 option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
 option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
 set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer")
 
 project(CSE2 LANGUAGES C CXX)
 
+# Has to be placed after "project()"
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
+	set(COMPILER_IS_CLANG true)
+	message(STATUS "Compiling with clang")
+endif()
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+	# Using GCC
+	set(COMPILER_IS_GCC true)
+	message(STATUS "Compiling with gcc")
+endif()
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+	# Using Intel C++
+	set(COMPILER_IS_ICC true)
+	message(STATUS "Compiling with ICC")
+endif()
+
+if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
+	set(COMPILER_IS_GCC_COMPATIBLE true)
+	message(STATUS "Compiling with a GCC-compatible compiler")
+endif()
+
 if(MSVC)
 	# Statically-link the CRT (vcpkg static libs do this)
 	foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
@@ -247,6 +274,62 @@ if(DEBUG_SAVE)
 	target_compile_definitions(CSE2 PRIVATE DEBUG_SAVE)
 endif()
 
+if (WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /W4 on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /W4)
+		# endif()
+
+		target_compile_options(CSE2 PRIVATE /W4)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(CSE2 PRIVATE -Wall -Wextra -pedantic)
+	else()
+		message(WARNING "Could not activate warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (ALL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /Wall on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/Wall" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /Wall)
+		# endif()
+
+		target_compile_options(CSE2 PRIVATE /Wall)
+	elseif(COMPILER_IS_CLANG)
+		target_compile_options(CSE2 PRIVATE -Weverything)
+	else()
+		message(WARNING "Could not activate all warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (FATAL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		target_compile_options(CSE2 PRIVATE /WX)
+		target_compile_options(bin2h PRIVATE /WX)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(CSE2 PRIVATE -Werror)
+		target_compile_options(bin2h PRIVATE -Werror)
+	else()
+		message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
 if(RENDERER MATCHES "OpenGL3")
 	target_sources(CSE2 PRIVATE "src/Backends/Rendering/OpenGL3.cpp")
 elseif(RENDERER MATCHES "SDLTexture")
@@ -281,6 +364,9 @@ ExternalProject_Add(bin2h
 	CMAKE_ARGS
 		-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
 		-DCMAKE_BUILD_TYPE=Release
+		-DWARNINGS=${WARNINGS}
+		-DALL_WARNINGS=${ALL_WARNINGS}
+		-DFATAL_WARNINGS=${FATAL_WARNINGS}
 	INSTALL_COMMAND
 		${CMAKE_COMMAND} --build . --config Release --target install
 )
diff --git a/Makefile b/Makefile
index 7fcd7b34..13f28f74 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,23 @@ ifeq ($(DEBUG_SAVE), 1)
 	CXXFLAGS += -DDEBUG_SAVE
 endif
 
+ifeq ($(WARNINGS), 1)
+	CXXFLAGS += -Wall -Wextra -pedantic
+endif
+
+ifeq ($(ALL_WARNINGS), 1)
+	ifneq ($(findstring clang,$(CXX),)
+		# Use clang-specific flag -Weverything
+		CXXFLAGS += -Weverything
+	else
+		@echo Couldn\'t activate all warnings (Unsupported compiler)
+	endif
+endif
+
+ifeq ($(FATAL_WARNINGS), 1)
+	CXXFLAGS += -Werror
+endif
+
 CXXFLAGS += -std=c++98 -MMD -MP -MF $@.d `$(PKG_CONFIG) sdl2 --cflags` `$(PKG_CONFIG) freetype2 --cflags`
 
 ifeq ($(STATIC), 1)
diff --git a/README.md b/README.md
index e7754644..d7a45f40 100644
--- a/README.md
+++ b/README.md
@@ -63,6 +63,9 @@ Name | Function
 `-DFIX_BUGS=ON` | Fix various bugs in the game
 `-DDEBUG_SAVE=ON` | Re-enable the ability to drag-and-drop save files onto the window
 `-DFORCE_LOCAL_LIBS=ON` | Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones
+`-DWARNINGS=ON` | Enable common warnings
+`-DALL_WARNINGS=ON` | Enable ALL warnings (clang/MSVC-only)
+`-DFATAL_WARNINGS=ON` | Make all warnings errors
 `-DRENDERER=OpenGL3` | Use the hardware-accelerated OpenGL 3.2 renderer
 `-DRENDERER=SDLTexture` | Use the hardware-accelerated SDL2 Texture API renderer (default)
 `-DRENDERER=SDLSurface` | Use the software-rendered SDL2 Surface API renderer
@@ -92,6 +95,9 @@ Name | Function
 `FIX_BUGS=1` | Fix various bugs in the game
 `WINDOWS=1` | Build for Windows
 `DEBUG_SAVE=1` | Re-enable the ability to drag-and-drop save files onto the window
+`WARNINGS=1` | Enable common warnings
+`ALL_WARNINGS=1` | Enable ALL warnings (clang/MSVC only)
+`FATAL_WARNINGS=1` | Make all warnings errors
 `RENDERER=OpenGL3` | Use the hardware-accelerated OpenGL 3.2 renderer
 `RENDERER=SDLTexture` | Use the hardware-accelerated SDL2 Texture API renderer (default)
 `RENDERER=SDLSurface` | Use the software-rendered SDL2 Surface API renderer
diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt
index f4dbd025..b8ea86e7 100644
--- a/bin2h/CMakeLists.txt
+++ b/bin2h/CMakeLists.txt
@@ -6,6 +6,30 @@ endif()
 
 project(bin2h LANGUAGES C)
 
+# Has to be placed after "project()"
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
+	set(COMPILER_IS_CLANG true)
+	message(STATUS "Compiling with clang")
+endif()
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+	# Using GCC
+	set(COMPILER_IS_GCC true)
+	message(STATUS "Compiling with gcc")
+endif()
+
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+	# Using Intel C++
+	set(COMPILER_IS_ICC true)
+	message(STATUS "Compiling with ICC")
+endif()
+
+if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
+	set(COMPILER_IS_GCC_COMPATIBLE true)
+	message(STATUS "Compiling with a GCC-compatible compiler")
+endif()
+
 add_executable(bin2h "bin2h.c")
 
 set_target_properties(bin2h PROPERTIES
@@ -14,6 +38,63 @@ set_target_properties(bin2h PROPERTIES
 	C_EXTENSIONS OFF
 )
 
+
+if (WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /W4 on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /W4)
+		# endif()
+
+		target_compile_options(bin2h PRIVATE /W4)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(bin2h PRIVATE -Wall -Wextra -pedantic)
+	else()
+		message(WARNING "Could not activate warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (ALL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /Wall on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/Wall" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /Wall)
+		# endif()
+
+		target_compile_options(bin2h PRIVATE /Wall)
+	elseif(COMPILER_IS_CLANG)
+		target_compile_options(bin2h PRIVATE -Weverything)
+	else()
+		message(WARNING "Could not activate all warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (FATAL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		target_compile_options(CSE2 PRIVATE /WX)
+		target_compile_options(bin2h PRIVATE /WX)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(CSE2 PRIVATE -Werror)
+		target_compile_options(bin2h PRIVATE -Werror)
+	else()
+		message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
 # MSVC tweak
 if(MSVC)
 	target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS)	# Disable warnings that normally fire up on MSVC when using "unsafe" functions instead of using MSVC's "safe" _s functions

From d6ec92cba5885dbca1ad11464e08ce5be74e20af Mon Sep 17 00:00:00 2001
From: Gabriel Ravier <gabravier@gmail.com>
Date: Sun, 27 Oct 2019 21:02:59 +0100
Subject: [PATCH 2/5] Attempt 2 at making warnings work

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
---
 CMakeLists.txt       |  4 ++--
 bin2h/CMakeLists.txt | 47 ++++++++++++++++++++++----------------------
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 107e0cef..575926a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,13 +25,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 	message(STATUS "Compiling with clang")
 endif()
 
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 	# Using GCC
 	set(COMPILER_IS_GCC true)
 	message(STATUS "Compiling with gcc")
 endif()
 
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
 	# Using Intel C++
 	set(COMPILER_IS_ICC true)
 	message(STATUS "Compiling with ICC")
diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt
index b8ea86e7..0184f487 100644
--- a/bin2h/CMakeLists.txt
+++ b/bin2h/CMakeLists.txt
@@ -6,30 +6,6 @@ endif()
 
 project(bin2h LANGUAGES C)
 
-# Has to be placed after "project()"
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
-	set(COMPILER_IS_CLANG true)
-	message(STATUS "Compiling with clang")
-endif()
-
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-	# Using GCC
-	set(COMPILER_IS_GCC true)
-	message(STATUS "Compiling with gcc")
-endif()
-
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
-	# Using Intel C++
-	set(COMPILER_IS_ICC true)
-	message(STATUS "Compiling with ICC")
-endif()
-
-if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
-	set(COMPILER_IS_GCC_COMPATIBLE true)
-	message(STATUS "Compiling with a GCC-compatible compiler")
-endif()
-
 add_executable(bin2h "bin2h.c")
 
 set_target_properties(bin2h PROPERTIES
@@ -38,6 +14,29 @@ set_target_properties(bin2h PROPERTIES
 	C_EXTENSIONS OFF
 )
 
+# Has to be placed after "project()"
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
+	set(COMPILER_IS_CLANG true)
+	message(STATUS "Compiling with clang")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+	# Using GCC
+	set(COMPILER_IS_GCC true)
+	message(STATUS "Compiling with gcc")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+	# Using Intel C++
+	set(COMPILER_IS_ICC true)
+	message(STATUS "Compiling with ICC")
+endif()
+
+if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
+	set(COMPILER_IS_GCC_COMPATIBLE true)
+	message(STATUS "Compiling with a GCC-compatible compiler")
+endif()
 
 if (WARNINGS)
 	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))

From 01abc0541a9840b835ed934f4ecac7d1d5a1a650 Mon Sep 17 00:00:00 2001
From: Gabriel Ravier <gabravier@gmail.com>
Date: Sun, 27 Oct 2019 21:22:10 +0100
Subject: [PATCH 3/5] Added code that prints the compiler ID and fixed bin2h's
 compiler detection code to use the C compiler ID of the C++ compiler ID
 (which isn't available then as bin2h is in c)

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
---
 CMakeLists.txt       | 2 ++
 bin2h/CMakeLists.txt | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 575926a7..f141fb46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,8 @@ set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'Ope
 
 project(CSE2 LANGUAGES C CXX)
 
+message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
+
 # Has to be placed after "project()"
 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt
index 0184f487..757c7ffd 100644
--- a/bin2h/CMakeLists.txt
+++ b/bin2h/CMakeLists.txt
@@ -14,20 +14,22 @@ set_target_properties(bin2h PROPERTIES
 	C_EXTENSIONS OFF
 )
 
+message(STATUS "Compiler ID : ${CMAKE_C_COMPILER_ID}")
+
 # Has to be placed after "project()"
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+if (CMAKE_C_COMPILER_ID MATCHES "Clang")
 	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
 	set(COMPILER_IS_CLANG true)
 	message(STATUS "Compiling with clang")
 endif()
 
-if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
 	# Using GCC
 	set(COMPILER_IS_GCC true)
 	message(STATUS "Compiling with gcc")
 endif()
 
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
 	# Using Intel C++
 	set(COMPILER_IS_ICC true)
 	message(STATUS "Compiling with ICC")

From d40376ff3500d86f8b3989060793d46d09c06eb6 Mon Sep 17 00:00:00 2001
From: Gabriel Ravier <gabravier@gmail.com>
Date: Tue, 29 Oct 2019 10:03:13 +0100
Subject: [PATCH 4/5] Removed bin2h mentions in CMakeLists, moved warnings
 options and FORCE_LOCAL_LIBS into a seperate block where the descriptions
 were improved and added warnings to DoConfig

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
---
 CMakeLists.txt          | 16 +++++----
 DoConfig/CMakeLists.txt | 80 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f141fb46..446b347b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,13 +9,14 @@ set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
 
 option(JAPANESE "Enable the Japanese-language build" OFF)
 option(FIX_BUGS "Fix various bugs in the game" OFF)
-option(WARNINGS "Enable common warnings" OFF)
-option(ALL_WARNINGS "Enable ALL warnings (clang/MSVC-only)" OFF)
-option(FATAL_WARNINGS "Stop compilation on any warnings" OFF)
 option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
-option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
 set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer")
 
+option(WARNINGS "Enable common compiler warnings (for gcc-compatible compilers and MSVC only)" OFF)
+option(ALL_WARNINGS "Enable ALL compiler warnings (for clang and MSVC only)" OFF)
+option(FATAL_WARNINGS "Stop compilation on any compiler warning (for gcc-compatible compilers and MSVC only)" OFF)
+option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
+
 project(CSE2 LANGUAGES C CXX)
 
 message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
@@ -323,10 +324,8 @@ if (FATAL_WARNINGS)
 
 	if (MSVC)
 		target_compile_options(CSE2 PRIVATE /WX)
-		target_compile_options(bin2h PRIVATE /WX)
 	elseif(COMPILER_IS_GCC_COMPATIBLE)
 		target_compile_options(CSE2 PRIVATE -Werror)
-		target_compile_options(bin2h PRIVATE -Werror)
 	else()
 		message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
 	endif()
@@ -513,6 +512,11 @@ endif()
 # DoConfig
 ##
 
+# Set warning options for DoConfig
+set(WARNINGS ${WARNINGS} FORCE BOOL)
+set(ALL_WARNINGS ${ALL_WARNINGS} FORCE BOOL)
+set(FATAL_WARNINGS ${FATAL_WARNINGS} FORCE BOOL)
+
 add_subdirectory("DoConfig")
 
 # Name debug builds "DoConfig_debug", to distinguish them
diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt
index fcf469b9..c3a39735 100644
--- a/DoConfig/CMakeLists.txt
+++ b/DoConfig/CMakeLists.txt
@@ -8,8 +8,88 @@ option(FORCE_LOCAL_LIBS "Compile the built-in version of FLTK instead of using t
 
 project(DoConfig LANGUAGES CXX)
 
+message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
+
+# Has to be placed after "project()"
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+	# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
+	set(COMPILER_IS_CLANG true)
+	message(STATUS "Compiling with clang")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+	# Using GCC
+	set(COMPILER_IS_GCC true)
+	message(STATUS "Compiling with gcc")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+	# Using Intel C++
+	set(COMPILER_IS_ICC true)
+	message(STATUS "Compiling with ICC")
+endif()
+
+if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
+	set(COMPILER_IS_GCC_COMPATIBLE true)
+	message(STATUS "Compiling with a GCC-compatible compiler")
+endif()
+
 add_executable(DoConfig "DoConfig.cpp" "icon.rc")
 
+if (WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /W4 on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /W4)
+		# endif()
+
+		target_compile_options(DoConfig PRIVATE /W4)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(DoConfig PRIVATE -Wall -Wextra -pedantic)
+	else()
+		message(WARNING "Could not activate warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (ALL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		# Force to always compile with /Wall on MSVC
+
+		# Can't do this with target_compile_options
+		# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+		# 	string(REGEX REPLACE "/W[0-4]" "/Wall" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+		# else()
+		# 	target_compile_options(CSE2 PRIVATE /Wall)
+		# endif()
+
+		target_compile_options(DoConfig PRIVATE /Wall)
+	elseif(COMPILER_IS_CLANG)
+		target_compile_options(DoConfig PRIVATE -Weverything)
+	else()
+		message(WARNING "Could not activate all warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
+if (FATAL_WARNINGS)
+	# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
+
+	if (MSVC)
+		target_compile_options(DoConfig PRIVATE /WX)
+	elseif(COMPILER_IS_GCC_COMPATIBLE)
+		target_compile_options(DoConfig PRIVATE -Werror)
+	else()
+		message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
+	endif()
+endif()
+
 # Windows tweak
 if(WIN32)
 	set_target_properties(DoConfig PROPERTIES WIN32_EXECUTABLE YES)	# Disable the console window

From f6c19c5501f40c437f17d9a3354bd4996b8da3b0 Mon Sep 17 00:00:00 2001
From: Gabriel Ravier <gabravier@gmail.com>
Date: Tue, 29 Oct 2019 10:07:43 +0100
Subject: [PATCH 5/5] Move warnings in the README too

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
---
 CMakeLists.txt | 2 +-
 README.md      | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 446b347b..8e3d3f99 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ endif()
 set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/game")
 set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
 
-option(JAPANESE "Enable the Japanese-language build" OFF)
+option(JAPANESE "Enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)" OFF)
 option(FIX_BUGS "Fix various bugs in the game" OFF)
 option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
 set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer")
diff --git a/README.md b/README.md
index d7a45f40..d1cb069c 100644
--- a/README.md
+++ b/README.md
@@ -62,14 +62,14 @@ Name | Function
 `-DJAPANESE=ON` | Enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
 `-DFIX_BUGS=ON` | Fix various bugs in the game
 `-DDEBUG_SAVE=ON` | Re-enable the ability to drag-and-drop save files onto the window
-`-DFORCE_LOCAL_LIBS=ON` | Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones
-`-DWARNINGS=ON` | Enable common warnings
-`-DALL_WARNINGS=ON` | Enable ALL warnings (clang/MSVC-only)
-`-DFATAL_WARNINGS=ON` | Make all warnings errors
 `-DRENDERER=OpenGL3` | Use the hardware-accelerated OpenGL 3.2 renderer
 `-DRENDERER=SDLTexture` | Use the hardware-accelerated SDL2 Texture API renderer (default)
 `-DRENDERER=SDLSurface` | Use the software-rendered SDL2 Surface API renderer
 `-DRENDERER=Software` | Use the handwritten software renderer
+`-DWARNINGS=ON` | Enable common compiler warnings (for gcc-compatible compilers and MSVC only)
+`-DALL_WARNINGS=ON` | Enable ALL compiler warnings (for clang and MSVC only)
+`-DFATAL_WARNINGS=ON` | Stop compilation on any compiler warning (for gcc-compatible compilers and MSVC only)
+`-DFORCE_LOCAL_LIBS=ON` | Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones
 
 Then compile CSE2 with this command: