Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
CMake code review
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Aug 17, 2024
1 parent 78872b4 commit d3bdb91
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions build/CompilerAndLinker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,40 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
list(APPEND COMPILER_SWITCHES /Zc:__cplusplus /Zc:inline /fp:fast /Qdiag-disable:161)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
list(APPEND COMPILER_SWITCHES /sdl /permissive- /JMC- /Zc:__cplusplus /Zc:inline /fp:fast)
list(APPEND COMPILER_SWITCHES /sdl /Zc:inline /fp:fast)

if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
message(STATUS "Building using Whole Program Optimization")
list(APPEND COMPILER_SWITCHES $<$<NOT:$<CONFIG:Debug>>:/Gy /Gw>)
endif()

if(OpenMP_CXX_FOUND)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10)
list(APPEND COMPILER_SWITCHES /permissive-)
endif()

if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.11)
AND (OpenMP_CXX_FOUND
OR (XBOX_CONSOLE_TARGET STREQUAL "durango")))
# OpenMP in MSVC is not compatible with /permissive- unless you disable two-phase lookup
list(APPEND COMPILER_SWITCHES /Zc:twoPhase-)
endif()

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.14)
list(APPEND COMPILER_SWITCHES /Zc:__cplusplus)
endif()

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.15)
list(APPEND COMPILER_SWITCHES /JMC-)
endif()

if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20)
AND (XBOX_CONSOLE_TARGET STREQUAL "durango"))
list(APPEND COMPILER_SWITCHES /d2FH4-)
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
list(APPEND LINKER_SWITCHES -d2:-FH4-)
endif()
endif()

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
list(APPEND COMPILER_SWITCHES /ZH:SHA_256)
endif()
Expand All @@ -114,6 +136,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
list(APPEND COMPILER_SWITCHES /Zc:lambda)
endif()

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29)
list(APPEND COMPILER_SWITCHES /external:W4)
endif()

if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.31)
AND (XBOX_CONSOLE_TARGET STREQUAL "durango"))
list(APPEND COMPILER_SWITCHES /Zc:static_assert-)
Expand Down

0 comments on commit d3bdb91

Please sign in to comment.