Skip to content

Commit

Permalink
MSVC warning fixes due to multiple values being provided for the same…
Browse files Browse the repository at this point in the history
… compiler setting
  • Loading branch information
MennoVink committed Nov 12, 2024
1 parent 7fadbf0 commit 8b42467
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/CMake/CommonCppFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(FATAL_ERROR "Building with a gcc version less than 4.7.3 is not supported.")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /W4 /permissive-")
# MSVC generates warnings when multiple /W# arguments are provided. If the parent project already specified a
# desired warning level we need to replace that instead of adding another warning level.
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()
# MSVC generates warnings when multiple standards are defined. The parent project may use the CMAKE_CXX_STANDARD
# variable to select te standard. Unset it so that our library code is still compiled with latest.
unset(CMAKE_CXX_STANDARD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /permissive-")
endif()


Expand Down

0 comments on commit 8b42467

Please sign in to comment.