How to set "/MT" in swift/c++ project?

Hi,

I'm playing with swift cxx interop on Windows and trying to put a legacy c++ library project into a swiftpm project which is configured to use the legacy c++ library.

So the swiftpm project has 2 targets, one is executableTarget in swift, the other one is target in c++.

When I build the project by swift build -v, I got this message:

Write auxiliary file D:\project\SwiftMMM.build\x86_64-unknown-windows-msvc\debug\SwiftMMM.build\sources

C:\Users\ccccc\AppData\Local\Programs\Swift\Toolchains\6.0.2+Asserts\usr\bin\clang.exe -target x86_64-unknown-windows-msvc -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -I D:\project\SwiftMMM\Sources\MMM\include -ID:\project\SwiftMMM\Sources\MMM\atlMMM\include -D_MT -D_DLL -Xclang --dependent-lib=msvcrt -gdwarf -gdwarf -MD -MT dependencies -MF D:\project\SwiftMMM.build\x86_64-unknown-windows-msvc\debug\MMM.build\source.cpp.d -c D:\project\SwiftMMM\Sources\MMM\source.cpp -o D:\project\SwiftMMM.build\x86_64-unknown-windows-msvc\debug\MMM.build\source.cpp.o

I see the definition of -D_MT -D_DLL, so _MT and _DLL are defined. By document of /MD, -MT, -LD (Use Run-Time Library) | Microsoft Learn, it equals to /MD in Visual Studio.

But what if I what to use /MT? I guess it will define _MT only but not _DLL, is it possible in swiftpm target settings?

I tested with this code:

            cxxSettings: [
                .define("_DLL2")
            ]

it always adds new macro definitions (-D_DLL2), how can I remove some one? What I need is -U like in gcc: Preprocessor Options (Using the GNU Compiler Collection (GCC)), maybe something like .undefine("_DLL")

Question 1: Is it possible?
Question 2: Why does swift/cxx use _MT and _DLL by default?

This is not really possible today. This will require additional work through out the stack. The two modes are ABI incompatible, and we do not distribute the runtime built for /MT today as we do not even build it. I think that getting /MDd wired up would be a good first step towards this which would also allow better debugging for the dynamically linked cases. After that, addressing the limitation where we cannot build the standard library statically on Windows currently would be needed before we could support /MT builds.