Skip to content

Commit

Permalink
[cmake] msvc.cmake: Add more conformance options.
Browse files Browse the repository at this point in the history
FIx an error in the non-clang section that caused the common conformance
flags to be overwritten with the MSVC-only flags. Not sure if this will
break anything, and I can't build with MSVC at the moment...

Move "/Zc:throwingNew" into the same non-clang-cl block as the other
options.
  • Loading branch information
GerbilSoft committed Jan 19, 2025
1 parent a85a99a commit f293d6d
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions cmake/platform/msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ ENDIF()

# MSVC: C++ conformance settings
INCLUDE(CheckCXXCompilerFlag)
SET(CXX_CONFORMANCE_FLAGS "/Zc:__cplusplus" "/Zc:rvalueCast" "/Zc:ternary")
SET(CXX_CONFORMANCE_FLAGS "/Zc:__cplusplus" "/Zc:checkGwOdr" "/Zc:rvalueCast" "/Zc:templateScope" "/Zc:ternary")
IF(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CXX_CONFORMANCE_FLAGS "/Zc:externC" "/Zc:noexceptTypes")
# clang-cl enables certain conformance options by default,
# and these cause warnings to be printed if specified.
# Only enable these for original MSVC.
SET(CXX_CONFORMANCE_FLAGS ${CXX_CONFORMANCE_FLAGS} "/Zc:externC" "/Zc:noexceptTypes" "/Zc:throwingNew")
ENDIF(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
FOREACH(FLAG_TEST ${CXX_CONFORMANCE_FLAGS})
# CMake doesn't like certain characters in variable names.
Expand All @@ -121,18 +124,6 @@ FOREACH(FLAG_TEST ${CXX_CONFORMANCE_FLAGS})
UNSET(CXXFLAG_${FLAG_TEST_VARNAME})
ENDFOREACH()

# "/Zc:throwingNew" is always enabled on clang-cl, and causes
# warnings to be printed if it's specified.
# NOTE: "/Zc:throwingNew" was added in MSVC 2015.
IF(NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("/Zc:throwingNew" CXXFLAG__Zc_throwingNew)
IF(CXXFLAG__Zc_throwingNew)
SET(RP_CXX_FLAGS_COMMON "${RP_CXX_FLAGS_COMMON} /Zc:throwingNew")
ENDIF(CXXFLAG__Zc_throwingNew)
UNSET(CXXFLAG__Zc_throwingNew)
ENDIF(NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang)

# Disable warning C4996 (deprecated), then re-enable it.
# Otherwise, it gets handled as an error due to /sdl.
SET(RP_C_FLAGS_COMMON "${RP_C_FLAGS_COMMON} /wd4996 /w34996")
Expand Down

0 comments on commit f293d6d

Please sign in to comment.