cmake: move ENABLE_WARNINGS to a module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
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()