From 066b6d1d744b253da58cf1356db4c033561fa02c Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Fri, 1 Mar 2024 17:50:04 -0800 Subject: [PATCH] CMake: Specify modern Cxx interop flag when building SwiftCompilerSources. When building with a Swift 5.9 toolchain, we can specify the `-cxx-interoperability-mode` flag instead of the deprecated `-enable-experimental-cxx-interop` flag. --- SwiftCompilerSources/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SwiftCompilerSources/CMakeLists.txt b/SwiftCompilerSources/CMakeLists.txt index 9b88db45aa2ed..b469667a52649 100644 --- a/SwiftCompilerSources/CMakeLists.txt +++ b/SwiftCompilerSources/CMakeLists.txt @@ -98,10 +98,17 @@ function(add_swift_compiler_modules_library name) "DEPENDS" ${ARGN}) + # Prior to 5.9, we have to use the experimental flag for C++ interop. + if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9) + set(cxx_interop_flag "-enable-experimental-cxx-interop") + else() + set(cxx_interop_flag "-cxx-interoperability-mode=default") + endif() + set(swift_compile_options "-color-diagnostics" "-Xfrontend" "-validate-tbd-against-ir=none" - "-Xfrontend" "-enable-experimental-cxx-interop" + "${cxx_interop_flag}" "-Xfrontend" "-disable-target-os-checking" "-Xcc" "-std=c++17" "-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"