force to always compile with -Wall and -Werror in gcc/clang (and /W4, /WX in MSVC)
This commit is contained in:
parent
0245ae5157
commit
2cf7b213cc
@ -79,7 +79,7 @@ endif()
|
|||||||
target_include_directories(doctest_main PRIVATE "thirdparty/doctest")
|
target_include_directories(doctest_main PRIVATE "thirdparty/doctest")
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake
|
# https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake
|
||||||
if(MSVC)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
# Force to always compile with W4
|
# Force to always compile with W4
|
||||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
@ -87,6 +87,9 @@ if(MSVC)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Force to always compile with WX
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
||||||
|
|
||||||
# Disable warning C4389: '==': signed/unsigned mismatch
|
# Disable warning C4389: '==': signed/unsigned mismatch
|
||||||
# Disable warning C4309: 'static_cast': truncation of constant value
|
# Disable warning C4309: 'static_cast': truncation of constant value
|
||||||
# Disable warning C4566: character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252)
|
# Disable warning C4566: character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252)
|
||||||
@ -94,7 +97,13 @@ if(MSVC)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389 /wd4309 /wd4566 /wd4996")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4389 /wd4309 /wd4566 /wd4996")
|
||||||
|
|
||||||
# https://github.com/nlohmann/json/issues/1114
|
# https://github.com/nlohmann/json/issues/1114
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# Force to always compile with Wall and Werror
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
|
# https://github.com/nlohmann/json/issues/1114
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -bigobj")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user