Skip to content

Commit

Permalink
CMake: Reorganize flags for ClangCL usage
Browse files Browse the repository at this point in the history
Disable some non-supported flags on windows platforms, and
pull in some flags from the other windows support branches.

Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
  • Loading branch information
pheonixfirewingz and ADKaster committed Oct 11, 2024
1 parent c92d9cc commit 60283ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 18 additions & 3 deletions Meta/CMake/common_compile_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,23 @@ macro(add_swift_link_options)
add_link_options($<$<LINK_LANGUAGE:Swift>:${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
Expand Down Expand Up @@ -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()
4 changes: 3 additions & 1 deletion Meta/CMake/lagom_compile_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 60283ed

Please sign in to comment.