XAML C# cmake 构建中的文件冲突

XAML file conflict in C# cmake build

我这里有一个 C# CMake 项目,https://github.com/jarl-haggerty/cmake-test。它由两个包含 UserControl1.xaml 但具有不同命名空间的库组成。如果我生成 Visual Studio 2019 解决方案并在构建两个库之间交替,我在构建库一时会收到以下错误:

1>C:\Users\jarl\source\repos\test\One\UserControl1.xaml.cs(9,13,9,32): error CS0103: The name 'InitializeComponent' does not exist in the current context
1>C:\Users\jarl\source\repos\test\build\obj\x64\Debug\UserControl1.xaml(9,95,9,117): error CS1061: 'UserControl1' does not contain a definition for 'innerRect_MouseDownTwo' and no accessible extension method 'innerRect_MouseDownTwo' accepting a first argument of type 'UserControl1' could be found (are you missing a using directive or an assembly reference?)

如果我删除 obj/x64/Debug 中的所有文件,构建将再次开始。该文件夹似乎是两个库中构建文件的目标,从错误中可以看出 UserControl.xaml 的两个版本混淆了。 C++ 项目会将构建分隔在 One.dir 和 Two.dir 文件夹中。这是可以预料的吗?有解决方法吗?我正在尝试将一个 Visual Studio 项目与像这样的几个案例移植到 cmake。

如果我将 add_library 调用放在单独的 CMakeLists.txt 文件中(One/CMakeLists.txt 和 Two/CMakeLists.txt),那么构建 运行 在不同的文件中解决我的问题的文件夹。