1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

CMake: Add ENABLE_WARNINGS and ENABLE_WERROR build options

ENABLE_WARNINGS is enabled by default, with `-Wall` on GCC/Clang and
`/W4` on MSVC.

ENABLE_WERROR is disabled by default, treats warnings as errors.
This commit is contained in:
Rémi Verschelde 2020-01-11 01:58:33 +01:00 committed by Ethan Lee
parent 441955de5f
commit d4ee5dec1a

View file

@ -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
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wall $<$<BOOL:ENABLE_WERROR>:-Werror>>
$<$<CXX_COMPILER_ID:MSVC>:
/W4 $<$<BOOL:ENABLE_WERROR>:/WX>>)
ENDIF()
# Library information
ADD_LIBRARY(tinyxml-static STATIC ${XML_SRC})
ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC})