diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index e174fa84..16c25c85 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -3,6 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +# CMake Options +OPTION(ENABLE_WARNINGS "Enable compilation warnings" ON) +OPTION(ENABLE_WERROR "Treat compilation warnings as errors" OFF) + # Architecture Flags IF(APPLE) # Wow, Apple is a huge jerk these days huh? @@ -103,6 +107,17 @@ ELSE() ADD_EXECUTABLE(vvvvvv ${VVV_SRC}) ENDIF() +# Build options +IF(ENABLE_WARNINGS) + # The weird syntax is due to CMake generator expressions. + # Saves quite a few lines and boilerplate at the price of readability. + TARGET_COMPILE_OPTIONS(vvvvvv PRIVATE + $<$,$,$>: + -Wall $<$:-Werror>> + $<$: + /W4 $<$:/WX>>) +ENDIF() + # Library information ADD_LIBRARY(tinyxml-static STATIC ${XML_SRC}) ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC})