2016-06-15 12 views
0

私はCMakeのにユニバーサルWindowsプラットフォームでアプリケーションを移行しようとしていると構築するとき、私は次のエラーを受信して​​います:UWP cmakeのプロジェクトXamlCompilerエラーWMC1002

\src\windows-uwp\App.xaml : XamlCompiler error WMC1002: x:Class type 'langdetect.App' is not found in 'langdetect'  

私は、名前空間の名前を変更してしまうんでした移行中にCMakeのプロジェクト名と一致するようにしましたが、私はすべての参照を更新していると思います。すべてのC/C++コードがうまくコンパイルされます。

<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> 

App.xaml.h:私はこれがApp.xamlでCMakeの3.5.2およびVisual Studioコミュニティ2015

を使用してい

#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); 
}; 
} 

これはUWP特定のコードであります私のCMakeLists.txtファイルで:

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") 
+0

私はもっと冗長なログを見て、app.xaml.camp/hがXAMLコンパイラがapp.xamlに到達する前にコンパイルされていることを確認します。 –

答えて

1

他に誰かがこの問題を抱えている場合、私はそれをどのように修正したか投稿します。

CMakeは私のアプリケーションのVisual Studioプロジェクトファイルを正しく生成しませんでした。元のエラーを修正するには、私は生成されたVisual Studioプロジェクトファイル内の数行を変更するために必要な(.vcxproj)

<ItemGroup> 
    <Page Include="App.xaml"> 
     <SubType>Designer</SubType> 
    </Page> 
    <Page Include="MainPage.xaml"> 
     <SubType>Designer</SubType> 
    </Page> 
</ItemGroup> 

App.xamlはApplicationDefinitionタグの下に含まれる必要があるか、エラーWMC1002を受け取ることになります。

Iはこれに上記のコードを変更:

<ItemGroup> 
    <ApplicationDefinition Include="App.xaml"> 
     <SubType>Designer</SubType> 
    </ApplicationDefinition> 
    <Page Include="MainPage.xaml"> 
     <SubType>Designer</SubType> 
    </Page> 
</ItemGroup> 

この固定エラーWMC1002、しかし、私は、3つの以上のエラーを受信しました。

Generated Files\XamlTypeInfo.g.cpp(66): error C2039: 'MainPage': is not a member of 'langdetect' [build\langdetect.vcxproj] 
    include\windows-uwp\App.xaml.h(10): note: see declaration of 'langdetect' 
Generated Files\XamlTypeInfo.g.cpp(66): error C2065: 'MainPage': undeclared identifier [build\langdetect.vcxproj] 
Generated Files\XamlTypeInfo.g.cpp(82): error C2440: 'initializing': cannot convert from 'overloaded-function' to 'Platform::Object ^(__cdecl *)(void)' [build\langdetect.vcxproj] 
    Generated Files\XamlTypeInfo.g.cpp(82): note: None of the functions with this name in scope match the target type 

これを引き起こしていた原因を突き止めるには長い時間がかかりました。それでも、生成されたプロジェクトファイルに関する別の問題が原因です。 XAMLページの

<ClInclude Include="App.xaml.h" /> 
<ClInclude Include="MainPage.xaml.h" /> 

ClIncludeタグは子DependentUponタグが正しく機能するために必要に思えます。私は上記のコードを以下に変更し、私の問題を修正しました。

<ClInclude Include="App.xaml.h"> 
    <DependentUpon>App.xaml</DependentUpon> 
</ClInclude> 
<ClInclude Include="MainPage.xaml.h"> 
    <DependentUpon>MainPage.xaml</DependentUpon> 
</ClInclude> 

これはバグか私のCMakeLists.txtに問題があるかどうかはわかりません。

3

これは、2つの方法で固定することができます:Visual Studioで

  1. 、App.xaml、一般のプロパティには、あなたのCMakeLists.txtItem TypeXAML Application DefinitionからVisual Studio XAML Properties Page
  2. を設定し、次の行を追加します。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を参照してください。

関連する問題