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?