Make compiler flags for -Werror specific to GNU, Clang, or Intel

This commit is contained in:
Wenzel Jakob 2019-06-11 22:42:30 +02:00
parent 21c3911bd3
commit e11e71d85c

View File

@ -126,14 +126,14 @@ find_package(Boost 1.56)
function(pybind11_enable_warnings target_name) function(pybind11_enable_warnings target_name)
if(MSVC) if(MSVC)
target_compile_options(${target_name} PRIVATE /W4) target_compile_options(${target_name} PRIVATE /W4)
else() elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)")
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated) target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated)
endif() endif()
if(PYBIND11_WERROR) if(PYBIND11_WERROR)
if(MSVC) if(MSVC)
target_compile_options(${target_name} PRIVATE /WX) target_compile_options(${target_name} PRIVATE /WX)
else() elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)")
target_compile_options(${target_name} PRIVATE -Werror) target_compile_options(${target_name} PRIVATE -Werror)
endif() endif()
endif() endif()