Add cmake option for -Werror
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Sat, 1 Oct 2016 15:48:44 +0000 (18:48 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Sat, 1 Oct 2016 15:57:13 +0000 (18:57 +0300)
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
CMakeLists.txt

index d9bc30c8c5990b6c93c118628d5cb71ee4e6f11d..482771fcd2d3b6ad773593a262415313706239df 100644 (file)
@@ -18,6 +18,7 @@ ENDIF()
 string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
 
 option(BUILD_SHARED_LIBS "Build shared libs" FALSE)
+option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" FALSE)
 
 set(KMSXX_ENABLE_PYTHON ON CACHE BOOL "Enable Python wrappers")
 set(KMSXX_ENABLE_KMSCUBE OFF CACHE BOOL "Enable kmscube")
@@ -38,6 +39,11 @@ SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
 
 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
 
+if (TREAT_WARNINGS_AS_ERRORS)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+endif()
+
 # static link libc
 # set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")