mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49: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:
parent
441955de5f
commit
d4ee5dec1a
1 changed files with 15 additions and 0 deletions
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue