diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index ebb4a427f2896f..109b947e4eb6fb 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -666,9 +666,21 @@ if (CLR_CMAKE_HOST_UNIX) # a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets # replaced with a default value, and always gets expanded to an OS version. # https://gitlab.kitware.com/cmake/cmake/-/issues/20132 - # We need to disable the warning that -tagret replaces -mmacosx-version-min - set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option) - add_link_options(-Wno-overriding-t-option) + # We need to disable the warning that -target replaces -mmacosx-version-min + # + # With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both + check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-option) + else() + check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + set(DISABLE_OVERRIDING_MIN_VERSION_ERROR -Wno-overriding-t-option) + else() + message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.") + endif() + endif() + add_link_options(${DISABLE_OVERRIDING_MIN_VERSION_ERROR}) if(CLR_CMAKE_HOST_ARCH_ARM64) set(CLR_CMAKE_MACCATALYST_COMPILER_TARGET "arm64-apple-ios15.0-macabi") add_link_options(-target ${CLR_CMAKE_MACCATALYST_COMPILER_TARGET}) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index fabeafa41e3e79..89597c85659fd8 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -552,6 +552,27 @@ if(GCC) set(WARNINGS "${WARNINGS} -Qunused-arguments -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Wno-zero-length-array -Wno-asm-operand-widths") endif() + if (HOST_MACCAT) + # Somewhere between CMake 3.17 and 3.19.4, it became impossible to not pass + # a value for mmacosx-version-min (blank CMAKE_OSX_DEPLOYMENT_TARGET gets + # replaced with a default value, and always gets expanded to an OS version. + # https://gitlab.kitware.com/cmake/cmake/-/issues/20132 + # We need to disable the warning that -target replaces -mmacosx-version-min + # + # With https://github.com/llvm/llvm-project/commit/1c66d08b0137cef7761b8220d3b7cb7833f57cdb clang renamed the option so we need to check for both + check_c_compiler_flag("-Wno-overriding-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_OPTION) + set(WARNINGS "${WARNINGS} -Wno-overriding-option") + else() + check_c_compiler_flag("-Wno-overriding-t-option" COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + if (COMPILER_SUPPORTS_W_NO_OVERRIDING_T_OPTION) + set(WARNINGS "${WARNINGS} -Wno-overriding-t-option") + else() + message(FATAL_ERROR "Compiler does not support -Wno-overriding-option or -Wno-overriding-t-option, needed for Mac Catalyst builds.") + endif() + endif() + endif() + check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES) if(WERROR_INCOMPATIBLE_POINTER_TYPES) set(WERROR_C "${WERROR_C} -Werror=incompatible-pointer-types") diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 8bfbb710823937..d039812dfe45b0 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -540,8 +540,6 @@ JS_ENGINES = [NODE_JS] <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_VARIANT=maccatalyst" /> - - <_MonoCPPFLAGS Include="-Wno-overriding-t-option" /> <_MonoCFlags Condition="'$(TargetArchitecture)' == 'arm64'" Include="-target arm64-apple-ios$(MacCatalystVersionMin)-macabi" /> <_MonoCFlags Condition="'$(TargetArchitecture)' == 'x64'" Include="-target x86_64-apple-ios$(MacCatalystVersionMin)-macabi" /> <_MonoCFLAGS Condition="'$(TargetArchitecture)' == 'arm64'" Include="-arch arm64" />