| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <!--
- Copyright (c) 2019 Chris Burns <[email protected]>
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- CMake build driver
- All key properties are overridable from CLI (-p:PropName=PropVal) or PropertyGroup
- CMakeProjName - project name outputted to build log
- CMakeSourceDir - path to CMakeList.txt
- CMakeBinaryDir - path to drop all the outputs
- CMakeBuildType - any valid value of DCMAKE_BUILD_TYPE (applies to both config and build for VS)
- CMakeConfigBuildType - any valid value of DCMAKE_BUILD_TYPE (for posix CLI)
- CMakeVSArch - force an arch for VS generators (eg. -AWin32)
- CMakeVSToolset = force an msvc platform toolset (eg. -Tv141)
- CMakeGenerator - override the CMake generator
- CMakeHelpLink - link to repo or other magical site when error occurs
- -->
- <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <CMakeProjName Condition="'$(CMakeProjName)' == ''">enet</CMakeProjName>
- <CMakeSourceDir Condition="'$(CMakeSourceDir)' == ''">$(SlnDir)</CMakeSourceDir>
- <CMakeBinaryDir Condition="'$(CMakeBinaryDir)' == ''">$(SlnDir)build_cmake_enet</CMakeBinaryDir>
- <CMakeBuildType Condition="'$(CMakeBuildType)' == '' AND '$(Configuration)' == 'Debug'">Debug</CMakeBuildType>
- <CMakeBuildType Condition="'$(CMakeBuildType)' == '' AND '$(Configuration)' == 'Release'">Release</CMakeBuildType>
- <CMakeHelpLink Condition="'$(CMakeHelpLink)' == ''">https://github.com/SoftwareGuy/ENet-CSharp</CMakeHelpLink>
- <CMakeOpts Condition="'$(CMakeBuildType)' == 'Debug'">$(CMakeOpts) -DENET_DEBUG=ON</CMakeOpts>
- </PropertyGroup>
- <PropertyGroup Condition="'$(OSPlatformWindows)' != 'true'">
- <CMakeConfigBuildType Condition="'$(CMakeConfigBuildType)' == ''">-DCMAKE_BUILD_TYPE=$(CMakeBuildType)</CMakeConfigBuildType>
- </PropertyGroup>
-
- <Target Name="CMakeBuildClean" BeforeTargets="Clean">
- <Message Text="CMake -- cleaning project: $(CMakeProjName)" Importance="high" />
- <RemoveDir Directories="$(CMakeBinaryDir)"/>
- <MakeDir Directories="$(CMakeBinaryDir)"/>
- <OnError ExecuteTargets="CMakeCleanFailed" />
- </Target>
- <Target Name="CMakeCheckVSVersion" BeforeTargets="Build;VSTest" Condition="'$(OSPlatformWindows)' == 'true'">
- <Error Text="CMake -- Unidentified Visual Studio Version" Condition="'$(VisualStudioVersion)' == ''" />
- <PropertyGroup>
- <VisualStudioVersionMajor>$(VisualStudioVersion.Substring(0, 2))</VisualStudioVersionMajor>
- </PropertyGroup>
-
- <Error Text="CMake -- Unsupported Visual Studio Version: $(VisualStudioVersion)" Condition="'$(VisualStudioVersionMajor)' != '15' AND '$(VisualStudioVersionMajor)' != '16'" />
- <PropertyGroup Condition="'$(OSPlatformWindows)' == 'true'">
- <VCToolsVersion Condition="'$(VCToolsVersion)' == '' AND '$(VisualStudioVersionMajor)' == '15'">14.1</VCToolsVersion>
- <VCToolsVersion Condition="'$(VCToolsVersion)' == '' AND '$(VisualStudioVersionMajor)' == '16'">14.2</VCToolsVersion>
- <VCToolsVersionMajor>$(VCToolsVersion.Substring(0, 2))</VCToolsVersionMajor>
- <VCToolsVersionMinor>$(VCToolsVersion.Substring(3, 1))</VCToolsVersionMinor>
- <CMakeVSYear Condition="'$(VisualStudioVersionMajor)' == '15'">2017</CMakeVSYear>
- <CMakeVSYear Condition="'$(VisualStudioVersionMajor)' == '16'">2019</CMakeVSYear>
- <CMakeVSGenVer>$(VisualStudioVersionMajor) $(CMakeVSYear)</CMakeVSGenVer>
- <CMakeVSToolset Condition="'$(CMakeVSToolset)' == ''">-Tv$(VCToolsVersionMajor)$(VCToolsVersionMinor)</CMakeVSToolset>
- <CMakeVSToolset Condition="'$(CMakeVSToolset)' != ''"> $(CMakeVSToolset)</CMakeVSToolset>
- <CMakePlatform Condition="'$(CMakePlatform)' == ''">$(Platform)</CMakePlatform>
- <CMakePlatform Condition="'$(CMakePlatform)' == 'AnyCPU'">x64</CMakePlatform>
- </PropertyGroup>
- <PropertyGroup Condition="'$(CMakeVSYear)' == '2017'">
- <CMakeVSArch Condition="'$(CMakeVSArch)' == '' AND '$(CMakePlatform)' == 'x64'">Win64</CMakeVSArch>
- <CMakeVSArch Condition="'$(CMakeVSArch)' != ''"> $(CMakeVSArch)</CMakeVSArch>
- <CMakeGenerator Condition="'$(CMakeGenerator)' == ''">-G"Visual Studio $(CMakeVSGenVer)$(CMakeVSArch)"$(CMakeVSToolset)</CMakeGenerator>
- </PropertyGroup>
- <PropertyGroup Condition="'$(CMakeVSYear)' == '2019'">
- <CMakeVSArch Condition="'$(CMakeVSArch)' == '' AND '$(CMakePlatform)' == 'x86'">-AWin32</CMakeVSArch>
- <CMakeVSArch Condition="'$(CMakeVSArch)' != ''"> $(CMakeVSArch)</CMakeVSArch>
- <CMakeGenerator Condition="'$(CMakeGenerator)' == ''">-G"Visual Studio $(CMakeVSGenVer)"$(CMakeVSArch)$(CMakeVSToolset)</CMakeGenerator>
- </PropertyGroup>
- </Target>
- <Target Name="CMakeConfigTarget" BeforeTargets="Build;VSTest">
- <Message Text="CMake -- configuring $(CMakeBuildType) $(Platform): $(CMakeProjName)" Importance="high" />
- <MakeDir Directories="$(CMakeBinaryDir)" />
- <Message Text="CMake -- cmake $(CMakeGenerator) $(CMakeConfigBuildType) $(CMakeOpts) $(CMakeSourceDir)" Importance="high" />
- <Exec Command="cmake $(CMakeGenerator) $(CMakeConfigBuildType) $(CMakeOpts) $(CMakeSourceDir)" WorkingDirectory="$(CMakeBinaryDir)" StandardOutputImportance="low" StandardErrorImportance="high" />
- <OnError ExecuteTargets="CMakeBuildFailed" />
- </Target>
- <Target Name="CMakeBuildTarget" BeforeTargets="Build;VSTest">
- <Message Text="CMake -- building $(CMakeBuildType) $(Platform): $(CMakeProjName)" Importance="high" />
- <Message Text="CMake -- cmake --build . --config $(CMakeBuildType)" Importance="high" />
- <Exec Command="cmake --build . --config $(CMakeBuildType)" WorkingDirectory="$(CMakeBinaryDir)" StandardOutputImportance="low" StandardErrorImportance="high" />
- <OnError ExecuteTargets="CMakeBuildFailed" />
- </Target>
- <Target Name="CMakeBuildSuccess" BeforeTargets="Build;VSTest">
- <Message Text="CMake -- build succeeded: $(CMakeProjName)" Importance="high" />
- </Target>
- <Target Name="CMakeCleanFailed">
- <Warning Text="CMake -- the most common cause of CMake clean errors is file locking (eg. windows console in the build dir)" />
- <Warning Text="CMake -- please unlock or reboot and try cleaning again before filing an issue on github:" />
- <Warning Text="CMake -- https://github.com/SoftwareGuy/ENet-CSharp" />
- <Error Text="CMake -- build failed: $(CMakeProjName)" />
- </Target>
- <Target Name="CMakeBuildFailed">
- <Warning Text="CMake -- the most common cause of CMake build errors is changing config without cleaning" />
- <Warning Text="CMake -- please try cleaning and building again before filing an issue on github:" />
- <Warning Text="CMake -- https://github.com/SoftwareGuy/ENet-CSharp" />
- <Error Text="CMake -- build failed: $(CMakeProjName)" />
- </Target>
- </Project>
|