Commit f8a2dda8266e09540b9821e20bf081da2355b105

Edward Thomson 2018-02-05T15:21:37

cmake: move ENABLE_WARNINGS to a module

diff --git a/CMakeLists.txt b/CMakeLists.txt
index baadfe2..53f10ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,7 @@ INCLUDE(FindThreads)
 INCLUDE(FindStatNsec)
 INCLUDE(IdeSplitSources)
 INCLUDE(FeatureSummary)
+INCLUDE(EnableWarnings)
 
 # Build options
 #
@@ -191,21 +192,6 @@ ELSE ()
 
 	SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
 
-	MACRO(ENABLE_WARNINGS flag)
-		IF(ENABLE_WERROR)
-			ADD_C_FLAG_IF_SUPPORTED(-Werror=${flag})
-		ELSE()
-			ADD_C_FLAG_IF_SUPPORTED(-W${flag})
-		ENDIF()
-	ENDMACRO()
-
-	MACRO(DISABLE_WARNINGS flag)
-		ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
-		IF(ENABLE_WERROR)
-			ADD_C_FLAG_IF_SUPPORTED(-Wno-error=${flag})
-		ENDIF()
-	ENDMACRO()
-
 	ENABLE_WARNINGS(all)
 	ENABLE_WARNINGS(extra)
 
diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/Modules/EnableWarnings.cmake
new file mode 100644
index 0000000..e7d7d39
--- /dev/null
+++ b/cmake/Modules/EnableWarnings.cmake
@@ -0,0 +1,14 @@
+MACRO(ENABLE_WARNINGS flag)
+	IF(ENABLE_WERROR)
+		ADD_C_FLAG_IF_SUPPORTED(-Werror=${flag})
+	ELSE()
+		ADD_C_FLAG_IF_SUPPORTED(-W${flag})
+	ENDIF()
+ENDMACRO()
+
+MACRO(DISABLE_WARNINGS flag)
+	ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
+	IF(ENABLE_WERROR)
+		ADD_C_FLAG_IF_SUPPORTED(-Wno-error=${flag})
+	ENDIF()
+ENDMACRO()