diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-18 20:50:08 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-18 20:54:03 -0700 |
| commit | ccca198c1b1730b0241911cb56dc8e3504958b2a (patch) | |
| tree | a2dd9b8b087a09afdcecc5cbb3377bed15127eb2 /scripts/buildsystems | |
| download | vcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.tar.gz vcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.zip | |
Initial commit
Diffstat (limited to 'scripts/buildsystems')
| -rw-r--r-- | scripts/buildsystems/msbuild/applocal.ps1 | 27 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/vcpkg.targets | 58 | ||||
| -rw-r--r-- | scripts/buildsystems/vcpkg.cmake | 52 |
3 files changed, 137 insertions, 0 deletions
diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1 new file mode 100644 index 000000000..70528e078 --- /dev/null +++ b/scripts/buildsystems/msbuild/applocal.ps1 @@ -0,0 +1,27 @@ +[cmdletbinding()] +param([string]$targetBinary, [string]$installedDir, [string]$tlogFile) + +function resolve($targetBinary) { + $targetBinaryPath = Resolve-Path $targetBinary + $targetBinaryDir = Split-Path $targetBinaryPath -parent + + $a = $(link /dump /imports $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) + $a | % { + if (Test-Path "$installedDir\$_") { + if (Test-Path "$targetBinaryDir\$_") { + Write-Verbose "$_ is already present" + } + else { + Copy-Item $installedDir\$_ $targetBinaryDir + Write-Verbose "Copying $installedDir\$_ -> $_" + } + "$targetBinaryDir\$_" + if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" } + resolve("$targetBinaryDir\$_") + } else { + Write-Verbose "$installedDir\$_ not found" + } + } +} + +resolve($targetBinary)
\ No newline at end of file diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets new file mode 100644 index 000000000..3a74099f0 --- /dev/null +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -0,0 +1,58 @@ +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32||'"> + <VCPkgEnabled Condition="'$(VCPkgEnabled)' == ''">true</VCPkgEnabled> + <VCPkgTriplet Condition="'$(VCPkgTriplet)' == ''">x86-windows</VCPkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win32|Windows Store|10.0'"> + <VCPkgEnabled Condition="'$(VCPkgEnabled)' == ''">true</VCPkgEnabled> + <VCPkgTriplet Condition="'$(VCPkgTriplet)' == ''">x86-uwp</VCPkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64||'"> + <VCPkgEnabled Condition="'$(VCPkgEnabled)' == ''">true</VCPkgEnabled> + <VCPkgTriplet Condition="'$(VCPkgTriplet)' == ''">x64-windows</VCPkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'x64|Windows Store|10.0'"> + <VCPkgEnabled Condition="'$(VCPkgEnabled)' == ''">true</VCPkgEnabled> + <VCPkgTriplet Condition="'$(VCPkgTriplet)' == ''">x64-uwp</VCPkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'arm|Windows Store|10.0'"> + <VCPkgEnabled Condition="'$(VCPkgEnabled)' == ''">true</VCPkgEnabled> + <VCPkgTriplet Condition="'$(VCPkgTriplet)' == ''">arm-uwp</VCPkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(VCPkgEnabled)' == 'true'"> + <VCPkgConfiguration Condition="'$(VCPkgConfiguration)' == ''">$(Configuration)</VCPkgConfiguration> + <!-- Expected to ..\..\..\ over scripts\buildsystems\msbuild --> + <VCPkgRoot Condition="'$(VCPkgRoot)' == ''">$(MSBuildThisFileDirectory)..\..\..\installed\$(VCPkgTriplet)\</VCPkgRoot> + </PropertyGroup> + + <ItemDefinitionGroup Condition="'$(VCPkgEnabled)' == 'true'"> + <Link> + <AdditionalDependencies Condition="'$(VCPkgConfiguration)' == 'Debug'">$(VCPkgRoot)debug\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies Condition="'$(VCPkgConfiguration)' == 'Release'">$(VCPkgRoot)lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + <ClCompile> + <AdditionalIncludeDirectories>$(VCPkgRoot)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + + <Target Name="AppLocalFromInstalled" AfterTargets="CopyFilesToOutputDirectory" BeforeTargets="CopyLocalFilesOutputGroup" Condition="'$(VCPkgEnabled)' == 'true' and '$(OutputType)' == 'exe'"> + <WriteLinesToFile + File="$(TLogLocation)$(ProjectName).write.1u.tlog" + Lines="^$(OutputPath)$(TargetName).$(OutputType);" Encoding="Unicode"/> + <Exec Condition="'$(VCPkgConfiguration)' == 'Debug'" + Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(OutputPath)$(TargetName).$(OutputType)%22 %22$(VCPkgRoot)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" + ConsoleToMSBuild="true"> + <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" /> + </Exec> + <Exec Condition="'$(VCPkgConfiguration)' == 'Release'" + Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(OutputPath)$(TargetName).$(OutputType)%22 %22$(VCPkgRoot)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" + ConsoleToMSBuild="true"> + <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" /> + </Exec> + </Target> +</Project> diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake new file mode 100644 index 000000000..26cc8a57b --- /dev/null +++ b/scripts/buildsystems/vcpkg.cmake @@ -0,0 +1,52 @@ +if(NOT VCPKG_TOOLCHAIN) + if(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + else() + if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + else() + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + endif() + endif() + + if(WINDOWS_STORE OR WINDOWS_PHONE) + set(_VCPKG_TARGET_TRIPLET_PLAT uwp) + else() + set(_VCPKG_TARGET_TRIPLET_PLAT windows) + endif() + + set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT}) + + set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) + + if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) + list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/debug + ) + endif() + list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET} + ) + + include_directories(${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/include) + + option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON) + if(OVERRIDE_ADD_EXECUTABLE) + function(add_executable name) + _add_executable(${ARGV}) + add_custom_command(TARGET ${name} POST_BUILD + COMMAND powershell -executionpolicy remotesigned -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 + -targetBinary $<TARGET_FILE:${name}> + -installedDir "${_VCPKG_TOOLCHAIN_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin" + -OutVariable out + ) + endfunction() + endif() + set(VCPKG_TOOLCHAIN ON) +endif() |
