bur*_*e17 1 xaml cmake visual-c++ windows-10 uwp
我正在尝试将通用 Windows 平台应用程序迁移到 CMake,但在构建时收到以下错误:
\src\windows-uwp\App.xaml : XamlCompiler error WMC1002: x:Class type 'langdetect.App' is not found in 'langdetect'
Run Code Online (Sandbox Code Playgroud)
我确实在迁移期间更改了命名空间的名称以匹配 CMake 项目名称,但我几乎可以肯定我已经更新了所有引用。所有的 C/C++ 代码都编译得很好。我正在使用 CMake 3.5.2 和 Visual Studio Community 2015。
这是 App.xaml:
<Application
x:Class="langdetect.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:langdetect"
RequestedTheme="Light">
</Application>
Run Code Online (Sandbox Code Playgroud)
应用程序.xaml.h:
#pragma once
#include "App.g.h"
namespace langdetect
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
ref class App sealed
{
protected:
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
internal:
App();
private:
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
};
}
Run Code Online (Sandbox Code Playgroud)
这是我的 CMakeLists.txt 文件中的 UWP 特定代码:
include_directories(./include/windows-uwp)
ADD_MSVC_PRECOMPILED_HEADER("${CMAKE_CURRENT_SOURCE_DIR}/include/windows-uwp/pch.h" "${CMAKE_CURRENT_SOURCE_DIR}/src/windows-uwp/pch.cpp" SRC_FILES)
set (HEADER_FILES include/gui.h include/langdetect.h include/windows-uwp/App.xaml.h
include/windows-uwp/MainPage.xaml.h include/windows-uwp/langdetect-uap.h
include/windows-uwp/str-utils.h)
set (SRC_FILES src/windows-uwp/App.xaml.cpp src/langdetect.c src/gui.c src/windows-uwp/MainPage.xaml.cpp
src/windows-uwp/langdetect-uap.cpp src/windows-uwp/str-utils.cpp
src/windows-uwp/App.xaml
src/windows-uwp/MainPage.xaml)
set (CMAKE_CXX_FLAGS "/ZW /EHsc")
Run Code Online (Sandbox Code Playgroud)
这可以通过两种方式修复:
Item Type
为XAML Application Definition
Visual Studio XAML 属性页CMakeLists.txt
,添加以下行:set_source_files_properties(App.xaml PROPERTIES VS_XAML_TYPE ApplicationDefinition)
有关此 CMake 属性的说明,请参阅https://cmake.org/cmake/help/v3.6/prop_sf/VS_XAML_TYPE.html。
归档时间: |
|
查看次数: |
962 次 |
最近记录: |