From 0aab0db34ae309b090412da6e84f35cdc69d77e0 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Tue, 9 Jul 2019 14:03:39 +0200 Subject: [PATCH] cmake: Ensure that the changed flags appear before project() --- CMakeLists.txt | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acccd71..8e8c7c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,28 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") endif() endif() +# All Warnings, Extra Warnings, Pedantic +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # using Clang + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-missing-braces -Wmissing-field-initializers -Wno-c++98-compat-pedantic -Wold-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-switch-enum") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # GCC: -fpermissive is required as GCC does not allow the same template to be in different namespaces. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -fpermissive -Wno-long-long -Wno-missing-braces -Wmissing-field-initializers") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + # using Intel C++ +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # Force to always compile with W4 + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + endif() +endif() +# C++ Standard and Extensions +## Use C++17 and no non-standard extensions. +set(_CXX_STANDARD 17) +set(_CXX_EXTENSIONS OFF) + # Define Project project( obs-ffmpeg-encoder @@ -118,28 +140,6 @@ if (WIN32) ) endif() -# All Warnings, Extra Warnings, Pedantic -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # using Clang - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-missing-braces -Wmissing-field-initializers -Wno-c++98-compat-pedantic -Wold-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-switch-enum") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # GCC: -fpermissive is required as GCC does not allow the same template to be in different namespaces. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -fpermissive -Wno-long-long -Wno-missing-braces -Wmissing-field-initializers") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - # using Intel C++ -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Force to always compile with W4 - if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") - endif() -endif() -# C++ Standard and Extensions -## Use C++17 and no non-standard extensions. -set(_CXX_STANDARD 17) -set(_CXX_EXTENSIONS OFF) - ################################################################################ # Options ################################################################################