<?xml version="1.0" encoding="utf-8"?>
<!--
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt VS Tools.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-->

<!--
///////////////////////////////////////////////////////////////////////////////////////////////////
// Item type definition and default values
// -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Fail-safe import of default values
  // -->
  <Import
    Condition="'$(QtDefaultsLoaded)' != 'true'"
    Project="$(MSBuildThisFileDirectory)\qt_defaults.props"/>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Qt VS Project Format Version
  // -->
  <PropertyGroup>
    <QtVsProjectVersion>0</QtVsProjectVersion>
    <QtVsProjectMinVersion_Settings>300</QtVsProjectMinVersion_Settings>
    <QtVsProjectMinVersion_ClProperties>300</QtVsProjectMinVersion_ClProperties>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Keyword)' != ''">
    <QtVsProjectVersion Condition="'$(Keyword)' == 'Qt4VSv1.0'">200</QtVsProjectVersion>
    <QtVsProjectVersion Condition="$(Keyword.StartsWith('QtVS_v'))"
      >$([System.Convert]::ToInt32($(Keyword.Substring(6))))</QtVsProjectVersion>

    <QtVsProjectSettings Condition="$(QtVsProjectVersion) &gt;= $(QtVsProjectMinVersion_Settings)"
      >true</QtVsProjectSettings>
    <QtVsProjectSettings Condition="$(QtVsProjectVersion) &lt; $(QtVsProjectMinVersion_Settings)"
      >false</QtVsProjectSettings>

    <QtVsProjectClProperties
      Condition="$(QtVsProjectVersion) &gt;= $(QtVsProjectMinVersion_ClProperties)"
      >true</QtVsProjectClProperties>
    <QtVsProjectClProperties
      Condition="$(QtVsProjectVersion) &lt; $(QtVsProjectMinVersion_ClProperties)"
      >false</QtVsProjectClProperties>
  </PropertyGroup>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Setup Qt installation path
  // -->
  <PropertyGroup Condition="'$(QtVsProjectSettings)' == 'true'">
    <QtInstallDir Condition="Exists('$(QtInstall)')">$(QtInstall)</QtInstallDir>
    <QtInstallRegKey Condition="'$(QtInstall)' != ''"
      >$(QtVersionsRegKey)\$(QtInstall)</QtInstallRegKey>
    <QtInstallRegDir Condition="'$(QtInstallDir)' == '' AND '$(QtInstallRegKey)' != ''"
      >$([MSBuild]::GetRegistryValue('$(QtInstallRegKey)','InstallDir'))</QtInstallRegDir>
    <QtInstallDir Condition="'$(QtInstallDir)' == '' AND Exists('$(QtInstallRegDir)')"
      >$(QtInstallRegDir)</QtInstallDir>
    <QtInstallDir Condition="'$(QtInstallDir)' == '' AND !Exists('$(QtInstallRegDir)')"
      >ERROR: Qt install dir not found</QtInstallDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(QtInstallDir)' != ''">
    <QtToolsPath Condition="'$(QtToolsPath)' == ''"
      >$([System.IO.Path]::Combine('$(QtInstallDir)','$(QtPathBinaries)'))</QtToolsPath>
    <QtDllPath Condition="'$(QtDllPath)' == ''"
      >$([System.IO.Path]::Combine('$(QtInstallDir)','$(QtPathLibraryExecutables)'))</QtDllPath>
    <QTDIR>$(QtInstallDir)</QTDIR>
  </PropertyGroup>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Qt Variables Expansion
  // -->
  <PropertyGroup Condition="'$(QtVsProjectSettings)' == 'true'">
    <ConfigurationEscaped>$(Configuration.Replace(' ','_'))</ConfigurationEscaped>
    <PlatformEscaped>$(Platform.Replace(' ','_'))</PlatformEscaped>

    <!--// Path to Qt variables property file -->
    <QtVarsWorkDir
        >$([System.IO.Path]::Combine(
            '$(TEMP)', '$([System.IO.Path]::GetRandomFileName())'))\</QtVarsWorkDir>
    <QtVarsOutputDir
        >$([System.IO.Path]::Combine('$(ProjectDir)', '$(IntDir)', 'qmake'))</QtVarsOutputDir>
    <QtVarsFileNameWithoutExt
        >qtvars_$(PlatformEscaped)_$(ConfigurationEscaped)</QtVarsFileNameWithoutExt>
    <QtVarsFileName
        >$(QtVarsFileNameWithoutExt).props</QtVarsFileName>
    <QtVarsWorkPath
        >$(QtVarsWorkDir)$(QtVarsFileName)</QtVarsWorkPath>
    <QtVarsFilePath
        >$(QtVarsOutputDir)\$(QtVarsFileName)</QtVarsFilePath>
    <QtVarsIndexPathDesignTime
        >$(QtVarsOutputDir)\$(QtVarsFileNameWithoutExt).designtime.idx</QtVarsIndexPathDesignTime>
    <QtVarsDesignTime Condition="Exists('$(QtVarsIndexPathDesignTime)')"
        >$([System.String]::Copy($([System.IO.File]::ReadAllText('$(QtVarsIndexPathDesignTime)'))).Replace('&#xD;&#xA;',''))</QtVarsDesignTime>
  </PropertyGroup>

  <!--// Import Qt variables (full build) -->
  <Import
    Condition="'$(DesignTimeBuild)' != 'true' AND Exists('$(QtVarsFilePath)')"
    Project="$(QtVarsFilePath)"/>

  <!--// Import Qt variables (design-time build) -->
  <Import
    Condition="'$(DesignTimeBuild)' == 'true' AND Exists('$(QtVarsDesignTime)')"
    Project="$(QtVarsDesignTime)"/>

  <!--// Import Qt variables (fall-back) -->
  <Import
    Condition=
"'$(DesignTimeBuild)' == 'true' AND !Exists('$(QtVarsDesignTime)') AND Exists('$(QtVarsFilePath)')"
    Project="$(QtVarsFilePath)"/>

  <!--// Add Qt variables to compiler and linker options -->
  <ItemDefinitionGroup Condition="'$(QtVsProjectSettings)' == 'true'">
    <ClCompile>
      <PreprocessorDefinitions
        >$(Qt_DEFINES_);%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <AdditionalIncludeDirectories
        >$(Qt_INCLUDEPATH_);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalDependencies
        >$(Qt_LIBS_);%(AdditionalDependencies)</AdditionalDependencies>
      <AdditionalLibraryDirectories
        >$(Qt_LIBPATH_);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Add Qt DLL path to debugger definitions
  // -->
  <PropertyGroup>
    <LocalDebuggerEnvironment  Condition="'$(QtDllPath)' != ''"
      >PATH=%PATH%;$(QtDllPath)&#xD;&#xA;$(LocalDebuggerEnvironment)
    </LocalDebuggerEnvironment>
  </PropertyGroup>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // QML debugging
  // -->
  <PropertyGroup>
    <QmlDebug Condition="'$(QtQMLDebugEnable)' == 'true'"
      >-qmljsdebugger=file:$(ProjectGuid),block</QmlDebug>
    <LocalDebuggerCommandArguments
      >$(QmlDebug)</LocalDebuggerCommandArguments>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(QtVsProjectSettings)' == 'true'">
    <ClCompile Condition="'$(QtQMLDebugEnable)' == 'true'">
      <PreprocessorDefinitions
        >QT_QML_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Read subfolder dependencies (qt_import.props)
  // -->
  <PropertyGroup
    Condition="'$(VisualStudioVersion)' != '12.0' AND '$(VisualStudioVersion)' != '14.0'">
    <SubFolder>$([System.IO.Directory]::GetDirectories('$(MSBuildThisFileDirectory)'))</SubFolder>
    <SubFolderImports Condition="'$(SubFolder)' != ''"
      >$([System.String]::Join(
        '\qt_import.props;',
        $(SubFolder.Split(';'))))\qt_import.props</SubFolderImports>
    <QtImports>$(SubFolderImports.Split(';'))</QtImports>
    <SubFolder/>
    <SubFolderImports/>
  </PropertyGroup>
  <Import
    Condition="'$(VisualStudioVersion)' != '12.0' AND '$(VisualStudioVersion)' != '14.0'"
    Project="$(QtImports)"/>

  <!--
  /////////////////////////////////////////////////////////////////////////////////////////////////
  // Import subfolder props
  // -->
  <Import
    Condition="'$(VisualStudioVersion)' != '12.0' AND '$(VisualStudioVersion)' != '14.0'"
    Project="$(QtMsBuildProps)"/>
  <ImportGroup
    Condition="'$(VisualStudioVersion)' == '12.0' OR '$(VisualStudioVersion)' == '14.0'">
    <!--
        // WORKAROUND: In VS 2013 and VS 2015 importing a list of files does not work
        // REMOVE when support for VS 2015 is dropped
    -->
    <Import Project="$(MSBuildThisFileDirectory)\moc\qtmoc.props"/>
    <Import Project="$(MSBuildThisFileDirectory)\rcc\qtrcc.props"/>
    <Import Project="$(MSBuildThisFileDirectory)\qml\qtqml.props"/>
    <Import Project="$(MSBuildThisFileDirectory)\repc\qtrepc.props"/>
    <Import Project="$(MSBuildThisFileDirectory)\uic\qtuic.props"/>
  </ImportGroup>

</Project>
