Skip to content

Commit

Permalink
CMakeList.txt: update with VS2022
Browse files Browse the repository at this point in the history
  • Loading branch information
pinterf committed Dec 12, 2021
1 parent f76a702 commit 09ad1ed
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Visual Studio 2019 is supported from CMake 3.14.1

# Tested generators:
# Command line makefile generator
# "MinGW Makefiles": MSYS2/Mingw32 GCC 8.3, 10.3 build
# IDE project file generators
# "Visual Studio 15 2017" optional platform generator Win32 and x64
# "Visual Studio 16 2019" optional platform generator Win32 and x64
# not tested: "Visual Studio 17 2022"
# "Visual Studio 16 2019" optional platform generator Win32 and x64. optional toolset "v141_xp"
# "Visual Studio 17 2022" optional platform generator Win32 and x64. optional toolset "v141_xp"

# Intel C++ Compilers (Cmake 3.20 minimum):
# Howto: https://www.intel.com/content/www/us/en/developer/articles/technical/using-oneapi-compilers-with-cmake-in-visual-studio.html
Expand Down Expand Up @@ -43,6 +41,7 @@
CMAKE_MINIMUM_REQUIRED( VERSION 3.6.2 )
# VS2019: 3.14.1
# Intel 2021: 3.20
# VS2022: 3.21

# Get PROJECT_VERSION property from 'avs_core/core/version.h.in'
file(READ "avs_core/core/version.h.in" versioning)
Expand Down Expand Up @@ -114,7 +113,8 @@ endif()
IF( MSVC ) # Check for Visual Studio

#1910-1919 = VS 15.0 (v141 toolset) Visual Studio 2017
#1920 = VS 16.0 (v142 toolset) Visual Studio 2019
#1920-1929 = VS 16.0 (v142 toolset) Visual Studio 2019
#1930-1939 = VS 17.0 (v143 toolset) Visual Studio 2022

IF( MSVC_VERSION VERSION_LESS 1910 )
MESSAGE(FATAL_ERROR "Visual C++ 2017 or newer required.")
Expand Down Expand Up @@ -174,8 +174,9 @@ endif()
ENDIF()
ELSE()
IF(NOT CLANG_IN_VS STREQUAL "1")
# Setting CMAKE_GENERATOR_TOOLSET here has no effect, only when passed or set directly
# Setting CMAKE_GENERATOR_TOOLSET here has no effect, only when passed (-T option) or set directly, so we just check it
IF(CMAKE_GENERATOR_TOOLSET STREQUAL "v141_xp")
# v141_xp is still available in Visual Studio 2022
message("CMAKE_GENERATOR_TOOLSET is XP compatible: ${CMAKE_GENERATOR_TOOLSET}, extra XP options added")
# https://connect.microsoft.com/VisualStudio/feedback/details/1789709/visual-c-2015-runtime-broken-on-windows-server-2003-c-11-magic-statics
add_definitions("/Zc:threadSafeInit-")
Expand Down Expand Up @@ -234,11 +235,20 @@ endif()
message("MSVC flags: ${CompilerFlag}:${${CompilerFlag}}")
endforeach()
ELSE()
# MSVC
# Enable C++ with SEH exceptions
# Avoid an obnoxious 'overriding /EHsc with /EHa' warning when
# using something other than MSBuild
STRING( REPLACE "/EHsc" "/EHa" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
STRING( REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

# Behavior is new in Visual Studio 2022:
# Floating-point contractions (mul+add to fma) aren't generated by default under /fp:precise
# Enable it manually
if (NOT (MSVC_VERSION LESS 1930)) # at least VS2022
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:contract")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:contract")
endif()
ENDIF()
# Prevent VC++ from complaining about not using MS-specific functions
add_definitions("/D _CRT_SECURE_NO_WARNINGS /D _SECURE_SCL=0")
Expand Down

0 comments on commit 09ad1ed

Please sign in to comment.