From a77710e5cf7222c3c257be315ddd9a2ab36c1d68 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 4 Feb 2017 20:31:10 +0000 Subject: [PATCH] CMake: Add option DYNARMIC_WARNINGS_AS_ERRORS --- CMakeLists.txt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1d1191b..95a48c28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,18 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR) project(dynarmic CXX) +# Determine if we're built as a subproject (using add_subdirectory) +# or if this is the master project. +set(MASTER_PROJECT OFF) +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(MASTER_PROJECT ON) +endif() + # Dynarmic project options option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON) option(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF) -option(DYNARMIC_TESTS "Build tests" ON) +option(DYNARMIC_TESTS "Build tests" ${MASTER_PROJECT}) +option(DYNARMIC_WARNINGS_AS_ERRORS "Warnings as errors" ${MASTER_PROJECT}) # Set hard requirements for C++ set(CMAKE_CXX_STANDARD 14) @@ -40,9 +48,13 @@ if (MSVC) /Zi /Zo /EHsc - /WX /DNOMINMAX) + if (DYNARMIC_WARNINGS_AS_ERRORS) + list(APPEND DYNARMIC_CXX_FLAGS + /WX) + endif() + if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "LLVM-vs[0-9]+") list(APPEND DYNARMIC_CXX_FLAGS -Qunused-arguments @@ -53,7 +65,6 @@ if (MSVC) else() set(DYNARMIC_CXX_FLAGS -Wall - -Werror -Wextra -Wcast-qual -pedantic @@ -63,6 +74,11 @@ else() -Wno-missing-braces -fno-operator-names) + if (DYNARMIC_WARNINGS_AS_ERRORS) + list(APPEND DYNARMIC_CXX_FLAGS + -Werror) + endif() + if (ARCHITECTURE_x86_64) list(APPEND DYNARMIC_CXX_FLAGS -msse3)