aboutsummaryrefslogtreecommitdiffstats
path: root/examples/UserView/UserViewQml/UserViewQml.csproj
blob: e5906a3c9826c23a6b812a635073002d9c74f2f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\..\utils\LazyFactory\LazyFactory.csproj" />
    <ProjectReference Include="..\UserViewLib\UserViewLib.csproj" />
    <ProjectReference Include="..\..\..\src\Qt.DotNet.Adapter\Qt.DotNet.Adapter.csproj" />
  </ItemGroup>

  <Target Name="BuildNative" AfterTargets="CoreCompile" BeforeTargets="_CreateAppHost">
    <PropertyGroup>
      <QtDir Condition="'$(QtDir)' == ''">C:\lib\qt\6.8.0\msvc2022_64</QtDir>
      <QtDotNetDir Condition="'$(QtDotNetDir)' == ''">$(ProjectDir)\qtdotnet</QtDotNetDir>
      <QtNativeSource>$(TargetDir)\native_source</QtNativeSource>
      <QtNativeBuild>$(TargetDir)\native_build</QtNativeBuild>
      <QtDotNetInclude>$([System.IO.Path]::GetFullPath('$(ProjectDir)\..\..\..\include'))</QtDotNetInclude>
    </PropertyGroup>

    <ItemGroup>
      <QtDotNetGenerated Include="$(QtDotNetDir)\generated_files\*" />
      <Qml Include="$(ProjectDir)\*.qml" />
    </ItemGroup>

    <MakeDir Directories="$(QtNativeSource);$(QtNativeBuild)" />
    <Copy SkipUnchangedFiles="true" SourceFiles="@(QtDotNetGenerated);@(Qml)" DestinationFolder="$(QtNativeSource)" />

    <Message Importance="high" Text="Building native code..." />
    <PropertyGroup>
      <BuildNative>
        CALL "$(VsInstallRoot)\VC\Auxiliary\Build\vcvars64.bat" &gt; NUL
        SET CMAKE_PREFIX_PATH=$(QtDir);$(CMAKE_PREFIX_PATH)
        SET CXXFLAGS="-I$(QtDotNetInclude)" $(CXXFLAGS)
        CD "$(QtNativeBuild)"
        cmake -G Ninja -S ..\native_source
        cmake --build .
      </BuildNative>
    </PropertyGroup>
    <Exec Command="$(BuildNative)" />
    <Copy SkipUnchangedFiles="true" SourceFiles="$(QtNativeBuild)\qmlapp.exe" DestinationFolder="$(TargetDir)" />

    <Message Importance="high" Text="Deploying QML app..." />
    <PropertyGroup>
      <RunWinDeployQt>
        CD "$(TargetDir)"
        "$(QtDir)\bin\windeployqt.exe" --no-translations --no-compiler-runtime qmlapp.exe &gt; NUL
      </RunWinDeployQt>
    </PropertyGroup>
    <Exec Command="$(RunWinDeployQt)" />

    <PropertyGroup>
      <AppHostSourcePath>$(TargetDir)qmlapp.exe</AppHostSourcePath>
    </PropertyGroup>
  </Target>

  <Target Name="CleanNative" AfterTargets="Clean">
    <PropertyGroup>
      <CleanNative>
        CD "$(TargetDir)" &amp;&amp; RD /S /Q "$(TargetDir)" &gt; NUL 2&gt;&amp;1
      </CleanNative>
    </PropertyGroup>
    <Exec Command="$(CleanNative)" />
  </Target>

</Project>