unknown argument: '-cxx-interoperability-mode=default'

I am creating an Xcode project using xcode generator in Cmake. The project has a library which contains cpp files and swift files. I m trying to test swift-cpp interoperability that is introduced in xcode15 to perform direct cpp calls from swift and vice-versa. For this to work, we need to set a xcode build setting 'C++ and Objective-C Interoperability' which I m doing via cmake, Below is my cmake file:

cmake_minimum_required(VERSION 3.18)

project(CxxInterop LANGUAGES CXX Swift)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_Swift_LANGUAGE_VERSION 5.0)

add_executable(CxxInterop ./Sources/CxxInterop/main.swift
                          ./Sources/CxxInterop/Student.cpp
)

#include the directory with modulemap file and Student.hpp

target_include_directories(CxxInterop PUBLIC
  ${CMAKE_SOURCE_DIR}/Sources/CxxInterop)

#setting the xcode C++ and Objective-C Interoperability setting 

target_compile_options(CxxInterop PRIVATE
  "-cxx-interoperability-mode=default")

when building the generated xcode project I get the error unknown argument: '-cxx-interoperability-mode=default'.

However the weird thing is when I separate out the cpp code in a different library and swift files in a different one, then this works and I m able to invoke the cpp methods in my swift file after importing the clang module from the module map file.

Is there any reason to why having cpp and swift files in same library producing this error? I m following this link to setup the project via cmake.

unknown argument: '-cxx-interoperability-mode=default'
 
 
Q