From 60283ed392bcbd5385e41ad0b4b5e0db3a821468 Mon Sep 17 00:00:00 2001 From: pheonixfirewingz Date: Wed, 9 Oct 2024 22:38:58 +0100 Subject: [PATCH] CMake: Reorganize flags for ClangCL usage Disable some non-supported flags on windows platforms, and pull in some flags from the other windows support branches. Co-Authored-By: Andrew Kaster --- Meta/CMake/common_compile_options.cmake | 21 ++++++++++++++++++--- Meta/CMake/lagom_compile_options.cmake | 4 +++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Meta/CMake/common_compile_options.cmake b/Meta/CMake/common_compile_options.cmake index cbdba2c9498..4c4f28dbdc9 100644 --- a/Meta/CMake/common_compile_options.cmake +++ b/Meta/CMake/common_compile_options.cmake @@ -38,10 +38,23 @@ macro(add_swift_link_options) add_link_options($<$:${args}>) endmacro() +# FIXME: Rework these flags to remove the suspicious ones. +if (WIN32) + add_compile_options(-Wno-unknown-attributes) # [[no_unique_address]] is broken in MSVC ABI until next ABI break + add_compile_options(-Wno-reinterpret-base-class) + add_compile_options(-Wno-microsoft-unqualified-friend) # MSVC doesn't support unqualified friends + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # _s replacements not desired (or implemented on any other platform other than VxWorks) + add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS) # POSIX names are just fine, thanks + add_compile_definitions(_USE_MATH_DEFINES) + add_compile_definitions(NOMINMAX) + add_compile_definitions(WIN32_LEAN_AND_MEAN) + add_compile_definitions(NAME_MAX=255) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + add_compile_options(-Wno-deprecated-declarations) +endif() + if (MSVC) add_cxx_compile_options(/W4) - # do not warn about unused function - add_cxx_compile_options(/wd4505) # disable exceptions add_cxx_compile_options(/EHsc) # disable floating-point expression contraction @@ -110,4 +123,6 @@ if (NOT WIN32) add_cxx_link_options(-fstack-protector-strong) endif() -add_cxx_compile_options(-fstrict-flex-arrays=2) +if (NOT MSVC) + add_cxx_compile_options(-fstrict-flex-arrays=2) +endif() diff --git a/Meta/CMake/lagom_compile_options.cmake b/Meta/CMake/lagom_compile_options.cmake index 357cc2150b5..ad76966f75e 100644 --- a/Meta/CMake/lagom_compile_options.cmake +++ b/Meta/CMake/lagom_compile_options.cmake @@ -32,7 +32,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_cxx_compile_options(-Og) else() add_cxx_compile_options(-O2) - add_cxx_compile_options(-g1) + if (NOT MSVC) + add_cxx_compile_options(-g1) + endif() endif() function(add_cxx_linker_flag_if_supported flag)