enable_language(CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(MSVC)
    if(${CMAKE_CXX_FLAGS} MATCHES "/EHsc")
        string(REPLACE "/EHsc" "/EHs-c-" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
    endif()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gr /GR- /fp:fast /MP /sdl- /GS- /W4")
    if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O3 /Gy /Oi /Opar")
    elseif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od")
    endif()
endif()