diff options
| author | Jan HrubĂ˝ <jhruby.web@gmail.com> | 2017-03-13 08:56:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-13 08:56:05 +0100 |
| commit | 665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch) | |
| tree | f0167041edf71e90f2331b5025f603392a8de67a /scripts | |
| parent | 1bec0fcb73073b5b1719f454c368a63f1bff625e (diff) | |
| parent | 1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff) | |
| download | vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip | |
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'scripts')
36 files changed, 1297 insertions, 307 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 182155146..fea05964b 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -7,9 +7,12 @@ param( $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition $vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root -$gitHash = git rev-parse HEAD +$gitHash = "unknownhash" +if (Get-Command "git.exe" -ErrorAction SilentlyContinue) +{ + $gitHash = git rev-parse HEAD +} Write-Verbose("Git hash is " + $gitHash) -$gitStartOfHash = $gitHash.substring(0,6) $vcpkgSourcesPath = "$vcpkgRootDir\toolsrc" Write-Verbose("vcpkg Path " + $vcpkgSourcesPath) @@ -20,7 +23,11 @@ if (!(Test-Path $vcpkgSourcesPath)) try{ pushd $vcpkgSourcesPath - cmd /c "$env:VS140COMNTOOLS..\..\VC\vcvarsall.bat" x86 "&" msbuild "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /m + $msbuildExeWithPlatformToolset = & $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 + $msbuildExe = $msbuildExeWithPlatformToolset[0] + $platformToolset = $msbuildExeWithPlatformToolset[1] + $windowsSDK = & $scriptsDir\getWindowsSDK.ps1 + & $msbuildExe "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /p:PlatformToolset=$platformToolset /p:TargetPlatformVersion=$windowsSDK /m dirs.proj Write-Verbose("Placing vcpkg.exe in the correct location") diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1 index 70528e078..55680c1f6 100644 --- a/scripts/buildsystems/msbuild/applocal.ps1 +++ b/scripts/buildsystems/msbuild/applocal.ps1 @@ -2,11 +2,21 @@ param([string]$targetBinary, [string]$installedDir, [string]$tlogFile) function resolve($targetBinary) { - $targetBinaryPath = Resolve-Path $targetBinary + try + { + $targetBinaryPath = Resolve-Path $targetBinary -erroraction stop + } + catch [System.Management.Automation.ItemNotFoundException] + { + return + } $targetBinaryDir = Split-Path $targetBinaryPath -parent - $a = $(link /dump /imports $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) + $a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) $a | % { + if ([string]::IsNullOrEmpty($_)) { + continue + } if (Test-Path "$installedDir\$_") { if (Test-Path "$targetBinaryDir\$_") { Write-Verbose "$_ is already present" diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 3a74099f0..d1d804e94 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -1,57 +1,75 @@ <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> + <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> + <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> + <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-uwp</VcpkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '||'"> + <VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled> + <VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x86-windows</VcpkgTriplet> + </PropertyGroup> + + <PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == '|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> + <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> + <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> + <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 Condition="'$(VcpkgEnabled)' == 'true'"> + <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration> + <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\installed\$(VcpkgTriplet)\</VcpkgRoot> </PropertyGroup> - <ItemDefinitionGroup Condition="'$(VCPkgEnabled)' == 'true'"> + <ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'"> <Link> - <AdditionalDependencies Condition="'$(VCPkgConfiguration)' == 'Debug'">$(VCPkgRoot)debug\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies> - <AdditionalDependencies Condition="'$(VCPkgConfiguration)' == 'Release'">$(VCPkgRoot)lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies Condition="'$(VcpkgConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies> + <AdditionalDependencies Condition="'$(VcpkgConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies> + <AdditionalLibraryDirectories Condition="'$(VcpkgConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories> + <AdditionalLibraryDirectories Condition="'$(VcpkgConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories> </Link> <ClCompile> - <AdditionalIncludeDirectories>$(VCPkgRoot)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgRoot)include</AdditionalIncludeDirectories> </ClCompile> </ItemDefinitionGroup> - <Target Name="AppLocalFromInstalled" AfterTargets="CopyFilesToOutputDirectory" BeforeTargets="CopyLocalFilesOutputGroup" Condition="'$(VCPkgEnabled)' == 'true' and '$(OutputType)' == 'exe'"> + <Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile"> + <Message Text="Using triplet "$(VcpkgTriplet)" from "$(VcpkgRoot)"" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/> + <Message Text="Not using Vcpkg because VcpkgEnabled is "$(VcpkgEnabled)"" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/> + </Target> + + <Target Name="AppLocalFromInstalled" AfterTargets="CopyFilesToOutputDirectory" BeforeTargets="CopyLocalFilesOutputGroup;RegisterOutput" Condition="'$(VcpkgEnabled)' == 'true'"> <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"> + <Exec Condition="'$(VcpkgConfiguration)' == 'Debug'" + Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" + ConsoleToMSBuild="true" + StandardOutputImportance="Normal"> <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"> + <Exec Condition="'$(VcpkgConfiguration)' == 'Release'" + Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" + ConsoleToMSBuild="true" + StandardOutputImportance="Normal"> <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" /> </Exec> </Target> diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index bae8cc3f8..e7b2b20db 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -10,8 +10,25 @@ if(NOT VCPKG_TOOLCHAIN) set(_VCPKG_TARGET_TRIPLET_ARCH x64) elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$") set(_VCPKG_TARGET_TRIPLET_ARCH arm) - else() + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017") set(_VCPKG_TARGET_TRIPLET_ARCH x86) + else() + find_program(_VCPKG_CL cl) + if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(_VCPKG_CL MATCHES "arm/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + else() + message(FATAL_ERROR "Unable to determine target architecture.") + endif() endif() endif() @@ -21,32 +38,55 @@ if(NOT VCPKG_TOOLCHAIN) set(_VCPKG_TARGET_TRIPLET_PLAT windows) endif() - set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT}) - + set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)") + set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed) 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 + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug + ) + list(APPEND CMAKE_LIBRARY_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link ) endif() list(APPEND CMAKE_PREFIX_PATH - ${CMAKE_CURRENT_LIST_DIR}/../../installed/${_VCPKG_TARGET_TRIPLET} + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} + ) + list(APPEND CMAKE_LIBRARY_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link ) - 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 UnRestricted -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(Boost_COMPILER "-vc140") + + set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools) + + option(VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON) + function(add_executable name) + _add_executable(${ARGV}) + list(FIND ARGV "IMPORTED" IMPORTED_IDX) + if(IMPORTED_IDX EQUAL -1) + if(VCPKG_APPLOCAL_DEPS) + add_custom_command(TARGET ${name} POST_BUILD + COMMAND powershell -noprofile -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 + -targetBinary $<TARGET_FILE:${name}> + -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin" + -OutVariable out + ) + endif() + set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) + endif() + endfunction() + + function(add_library name) + _add_library(${ARGV}) + list(FIND ARGV "IMPORTED" IMPORTED_IDX) + list(FIND ARGV "INTERFACE" INTERFACE_IDX) + list(FIND ARGV "ALIAS" ALIAS_IDX) + if(IMPORTED_IDX EQUAL -1 AND INTERFACE_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1) + set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) + endif() + endfunction() + set(VCPKG_TOOLCHAIN ON) endif() diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake new file mode 100644 index 000000000..20e249c8b --- /dev/null +++ b/scripts/cmake/vcpkg_acquire_msys.cmake @@ -0,0 +1,30 @@ +function(vcpkg_acquire_msys PATH_TO_ROOT_OUT) + set(TOOLPATH ${DOWNLOADS}/tools/msys2) + set(TOOLSUBPATH msys32) + set(URL "https://sourceforge.net/projects/msys2/files/Base/i686/msys2-base-i686-20161025.tar.xz/download") + set(ARCHIVE "msys2-base-i686-20161025.tar.xz") + set(HASH c9260a38e0c6bf963adeaea098c4e376449c1dd0afe07480741d6583a1ac4c138951ccb0c5388bd148e04255a5c1a23bf5ee2d58dcd6607c14f1eaa5639a7c85) + + set(PATH_TO_ROOT ${TOOLPATH}/${TOOLSUBPATH}) + + if(NOT EXISTS "${TOOLPATH}/initialized-msys2.stamp") + message(STATUS "Acquiring MSYS2...") + file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} + EXPECTED_HASH SHA512=${HASH} + ) + file(REMOVE_RECURSE ${TOOLPATH}) + file(MAKE_DIRECTORY ${TOOLPATH}) + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + WORKING_DIRECTORY ${TOOLPATH} + ) + execute_process( + COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "PATH=/usr/bin:\$PATH;pacman-key --init;pacman-key --populate" + WORKING_DIRECTORY ${TOOLPATH} + ) + file(WRITE "${TOOLPATH}/initialized-msys2.stamp" "0") + message(STATUS "Acquiring MSYS2... OK") + endif() + + set(${PATH_TO_ROOT_OUT} ${PATH_TO_ROOT} PARENT_SCOPE) +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_apply_patches.cmake b/scripts/cmake/vcpkg_apply_patches.cmake index 939edbd14..1ef138a1e 100644 --- a/scripts/cmake/vcpkg_apply_patches.cmake +++ b/scripts/cmake/vcpkg_apply_patches.cmake @@ -1,18 +1,44 @@ +#.rst: +# .. command:: vcpkg_apply_patches +# +# Apply a set of patches to a source tree. +# +# :: +# vcpkg_apply_patches(SOURCE_PATH <source_path> +# PATCHES patch1 [patch ...] +# ) +# +# ``SOURCE_PATH`` +# The source path in which apply the patches. +# ``PATCHES`` +# A list of patches that are applied to the source tree +# ``QUIET`` +# If this option is passed, the warning message when applyng +# a patch fails is not printed. This is convenient for patches +# that are known to fail even on a clean source tree, and for +# which the standard warning message would be confusing for the user. +# + function(vcpkg_apply_patches) - cmake_parse_arguments(_ap "" "SOURCE_PATH" "PATCHES" ${ARGN}) + cmake_parse_arguments(_ap "QUIET" "SOURCE_PATH" "PATCHES" ${ARGN}) - find_program(GIT git) + find_program(GIT NAMES git git.cmd) set(PATCHNUM 0) foreach(PATCH ${_ap_PATCHES}) message(STATUS "Applying patch ${PATCH}") set(LOGNAME patch-${TARGET_TRIPLET}-${PATCHNUM}) execute_process( - COMMAND ${GIT} --work-tree=. apply "${PATCH}" --ignore-whitespace --whitespace=nowarn --verbose + COMMAND ${GIT} --work-tree=. --git-dir=.git apply "${PATCH}" --ignore-whitespace --whitespace=nowarn --verbose OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-out.log ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-err.log WORKING_DIRECTORY ${_ap_SOURCE_PATH} RESULT_VARIABLE error_code ) + + if(error_code AND NOT ${_ap_QUIET}) + message(STATUS "Applying patch failed. This is expected if this patch was previously applied.") + endif() + message(STATUS "Applying patch ${PATCH} done") math(EXPR PATCHNUM "${PATCHNUM}+1") endforeach() diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 33990d9b0..18e2a8b00 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -1,7 +1,31 @@ function(vcpkg_build_cmake) + cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN}) + + set(MSVC_EXTRA_ARGS + "/p:VCPkgLocalAppDataDisabled=true" + "/p:UseIntelMKL=No" + ) + + # Specifies the architecture of the toolset, NOT the architecture of the produced binary + # This can help libraries that cause the linker to run out of memory. + # https://support.microsoft.com/en-us/help/2891057/linker-fatal-error-lnk1102-out-of-memory + if (_bc_MSVC_64_TOOLSET) + list(APPEND MSVC_EXTRA_ARGS "/p:PreferredToolArchitecture=x64") + endif() + + if (NOT _bc_DISABLE_PARALLEL) + list(APPEND MSVC_EXTRA_ARGS "/m") + endif() + + if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja) + set(BUILD_ARGS -v) # verbose output + else() + set(BUILD_ARGS ${MSVC_EXTRA_ARGS}) + endif() + message(STATUS "Build ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release -- /p:VCPkgLocalAppDataDisabled=true + COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${BUILD_ARGS} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME build-${TARGET_TRIPLET}-rel ) @@ -9,7 +33,7 @@ function(vcpkg_build_cmake) message(STATUS "Build ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Debug -- /p:VCPkgLocalAppDataDisabled=true + COMMAND ${CMAKE_COMMAND} --build . --config Debug -- ${BUILD_ARGS} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME build-${TARGET_TRIPLET}-dbg ) diff --git a/scripts/cmake/vcpkg_build_msbuild.cmake b/scripts/cmake/vcpkg_build_msbuild.cmake index bf7c1b546..f4a809e7f 100644 --- a/scripts/cmake/vcpkg_build_msbuild.cmake +++ b/scripts/cmake/vcpkg_build_msbuild.cmake @@ -1,5 +1,42 @@ +#.rst: +# .. command:: vcpkg_build_msbuild +# +# Build a msbuild-based project. +# +# :: +# vcpkg_build_msbuild(PROJECT_PATH <sln_project_path> +# [RELEASE_CONFIGURATION <release_configuration>] # (default = "Release") +# [DEBUG_CONFIGURATION <debug_configuration>] @ (default = "Debug") +# [PLATFORM <platform>] # (default = "${TRIPLET_SYSTEM_ARCH}") +# [OPTIONS arg1 [arg2 ...]] +# [OPTIONS_RELEASE arg1 [arg2 ...]] +# [OPTIONS_DEBUG arg1 [arg2 ...]] +# ) +# +# ``PROJECT_PATH`` +# The path to the *.sln msbuild project file. +# ``RELEASE_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Release builds. +# ``DEBUG_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Debug builds. +# ``DEBUG_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Debug builds. +# ``PLATFORM`` +# The platform (``/p:Platform`` msbuild parameter) +# used for the build. +# ``OPTIONS`` +# The options passed to msbuild for all builds. +# ``OPTIONS_RELEASE`` +# The options passed to msbuild for Release builds. +# ``OPTIONS_DEBUG`` +# The options passed to msbuild for Debug builds. +# + function(vcpkg_build_msbuild) - cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION;PLATFORM" "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG" ${ARGN}) if(NOT DEFINED _csc_RELEASE_CONFIGURATION) set(_csc_RELEASE_CONFIGURATION Release) @@ -7,14 +44,19 @@ function(vcpkg_build_msbuild) if(NOT DEFINED _csc_DEBUG_CONFIGURATION) set(_csc_DEBUG_CONFIGURATION Debug) endif() + if(NOT DEFINED _csc_PLATFORM) + set(_csc_PLATFORM ${TRIPLET_SYSTEM_ARCH}) + endif() message(STATUS "Building ${_csc_PROJECT_PATH} for Release") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE} /p:Configuration=${_csc_RELEASE_CONFIGURATION} - /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:Platform=${_csc_PLATFORM} /p:VCPkgLocalAppDataDisabled=true + /p:UseIntelMKL=No + /m WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME build-${TARGET_TRIPLET}-rel ) @@ -24,9 +66,11 @@ function(vcpkg_build_msbuild) vcpkg_execute_required_process( COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG} /p:Configuration=${_csc_DEBUG_CONFIGURATION} - /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:Platform=${_csc_PLATFORM} /p:VCPkgLocalAppDataDisabled=true + /p:UseIntelMKL=No + /m WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME build-${TARGET_TRIPLET}-dbg ) -endfunction()
\ No newline at end of file +endfunction() diff --git a/scripts/cmake/vcpkg_build_qmake.cmake b/scripts/cmake/vcpkg_build_qmake.cmake new file mode 100644 index 000000000..263200423 --- /dev/null +++ b/scripts/cmake/vcpkg_build_qmake.cmake @@ -0,0 +1,36 @@ +#.rst: +# .. command:: vcpkg_build_qmake +# +# Build a qmake-based project, previously configured using vcpkg_configure_qmake . +# As the CONFIG qmake option is assumed to be "debug_and_release" (the default value on Windows, see [1]), +# both the debug and release libraries are build in the same build tree. +# +# :: +# vcpkg_build_qmake() +# +# +# [1] : http://doc.qt.io/qt-5/qmake-variable-reference.html + +function(vcpkg_build_qmake) + vcpkg_find_acquire_program("JOM") + + if(NOT JOM) + BUILD_ERROR("vcpkg_install_qmake: impossible to find jom.") + endif() + + # Make sure that the linker finds the libraries used + set(ENV_LIB_BACKUP ENV{LIB}) + set(ENV{LIB} "${CURRENT_INSTALLED_DIR}/lib;${CURRENT_INSTALLED_DIR}/debug/lib;$ENV{LIB}") + + message(STATUS "Package ${TARGET_TRIPLET}") + vcpkg_execute_required_process_repeat( + COUNT 2 + COMMAND ${JOM} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET} + LOGNAME package-${TARGET_TRIPLET} + ) + message(STATUS "Package ${TARGET_TRIPLET} done") + + # Restore the original value of ENV{LIB} + set(ENV{LIB} ENV_LIB_BACKUP) +endfunction() diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 59824eb17..a003548d5 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -1,10 +1,20 @@ +include(vcpkg_acquire_msys) include(vcpkg_download_distfile) include(vcpkg_extract_source_archive) include(vcpkg_execute_required_process) +include(vcpkg_execute_required_process_repeat) include(vcpkg_find_acquire_program) include(vcpkg_build_cmake) include(vcpkg_build_msbuild) +include(vcpkg_build_qmake) include(vcpkg_install_cmake) +include(vcpkg_install_meson) include(vcpkg_configure_cmake) +include(vcpkg_configure_meson) +include(vcpkg_configure_qmake) include(vcpkg_apply_patches) -include(vcpkg_copy_pdbs)
\ No newline at end of file +include(vcpkg_copy_pdbs) +include(vcpkg_copy_tool_dependencies) +include(vcpkg_get_program_files_32_bit) +include(vcpkg_get_program_files_platform_bitness) +include(vcpkg_get_windows_sdk)
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index aa85c8ff4..daf9dfd6f 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -1,35 +1,104 @@ -find_program(vcpkg_configure_cmake_NINJA ninja) function(vcpkg_configure_cmake) - cmake_parse_arguments(_csc "" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + cmake_parse_arguments(_csc "PREFER_NINJA" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + + if(NOT VCPKG_PLATFORM_TOOLSET) + message(FATAL_ERROR "Vcpkg has been updated with VS2017 support, however you need to rebuild vcpkg.exe by re-running bootstrap.ps1\n powershell -exec bypass scripts\\bootstrap.ps1\n") + endif() if(_csc_GENERATOR) set(GENERATOR ${_csc_GENERATOR}) - elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "x86") + elseif(_csc_PREFER_NINJA AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + set(GENERATOR "Ninja") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "x64") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") - elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "arm") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 ARM") - # elseif(NOT vcpkg_configure_cmake_NINJA MATCHES "NOTFOUND") - # set(GENERATOR "Ninja") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm") - set(GENERATOR "Visual Studio 14 2015 ARM") + set(GENERATOR "Visual Studio 14 2015 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 Win64") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 ARM") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 Win64") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm") + set(GENERATOR "Visual Studio 15 2017 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + endif() + + # If we use Ninja, make sure it's on PATH + if(GENERATOR STREQUAL "Ninja") + vcpkg_find_acquire_program(NINJA) + get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) + set(ENV{PATH} "$ENV{PATH};${NINJA_PATH}") endif() file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + if(DEFINED VCPKG_CMAKE_SYSTEM_NAME) + list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}) + endif() + if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}) + endif() + if(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=ON) + elseif(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL static) + list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=OFF) + endif() + + + list(APPEND _csc_OPTIONS + "-DCMAKE_CXX_FLAGS= /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP" + "-DCMAKE_C_FLAGS= /DWIN32 /D_WINDOWS /W3 /utf-8 /MP" + "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" + "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" + "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" + "-DBoost_COMPILER=-vc140" + "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TRIPLET_FILE}" + ) + if(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL dynamic) + list(APPEND _csc_OPTIONS_DEBUG + "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" + "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" + ) + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Zi" + "-DCMAKE_C_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Zi" + ) + elseif(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL static) + list(APPEND _csc_OPTIONS_DEBUG + "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" + "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" + ) + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Zi" + "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Zi" + ) + endif() + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF" + "-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF" + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE} -G ${GENERATOR} - -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR} -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel @@ -42,9 +111,7 @@ function(vcpkg_configure_cmake) vcpkg_execute_required_process( COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG} -G ${GENERATOR} - -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR}/debug\\\\\\\;${CURRENT_INSTALLED_DIR} -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg diff --git a/scripts/cmake/vcpkg_configure_meson.cmake b/scripts/cmake/vcpkg_configure_meson.cmake new file mode 100644 index 000000000..277f91e11 --- /dev/null +++ b/scripts/cmake/vcpkg_configure_meson.cmake @@ -0,0 +1,72 @@ +function(vcpkg_configure_meson) + cmake_parse_arguments(_vcm "" "SOURCE_PATH" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + + # use the same compiler options as in vcpkg_configure_cmake + set(MESON_COMMON_CFLAGS "${MESON_COMMON_CFLAGS} /DWIN32 /D_WINDOWS /W3 /utf-8") + set(MESON_COMMON_CXXFLAGS "${MESON_COMMON_CXXFLAGS} /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc") + + if(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL dynamic) + set(MESON_DEBUG_CFLAGS "${MESON_DEBUG_CFLAGS} /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + set(MESON_DEBUG_CXXFLAGS "${MESON_DEBUG_CXXFLAGS} /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") + + set(MESON_RELEASE_CFLAGS "${MESON_RELEASE_CFLAGS} /MD /O2 /Oi /Gy /DNDEBUG /Zi") + set(MESON_RELEASE_CXXFLAGS "${MESON_RELEASE_CXXFLAGS} /MD /O2 /Oi /Gy /DNDEBUG /Zi") + elseif(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL static) + set(MESON_DEBUG_CFLAGS "${MESON_DEBUG_CFLAGS} /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") + set(MESON_DEBUG_CXXFLAGS "${MESON_DEBUG_CXXFLAGS} /D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") + + set(MESON_RELEASE_CFLAGS "${MESON_RELEASE_CFLAGS} /MT /O2 /Oi /Gy /DNDEBUG /Zi") + set(MESON_RELEASE_CXXFLAGS "${MESON_RELEASE_CXXFLAGS} /MT /O2 /Oi /Gy /DNDEBUG /Zi") + endif() + + set(MESON_COMMON_LDFLAGS "${MESON_COMMON_LDFLAGS} /DEBUG") + set(MESON_RELEASE_LDFLAGS "${MESON_RELEASE_LDFLAGS} /INCREMENTAL:NO /OPT:REF /OPT:ICF") + + # select meson cmd-line options + list(APPEND _vcm_OPTIONS --buildtype plain --backend ninja) + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND _vcm_OPTIONS --default-library shared) + else() + list(APPEND _vcm_OPTIONS --default-library static) + endif() + + list(APPEND _vcm_OPTIONS_DEBUG --prefix ${CURRENT_PACKAGES_DIR}/debug --includedir ../include) + list(APPEND _vcm_OPTIONS_RELEASE --prefix ${CURRENT_PACKAGES_DIR}) + + vcpkg_find_acquire_program(MESON) + vcpkg_find_acquire_program(NINJA) + get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) + set(ENV{PATH} "$ENV{PATH};${NINJA_PATH}") + + # configure release + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_RELEASE_CFLAGS}") + set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_RELEASE_CXXFLAGS}") + set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_RELEASE_LDFLAGS}") + set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_RELEASE_CPPFLAGS}") + vcpkg_execute_required_process( + COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_RELEASE} ${_vcm_SOURCE_PATH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME config-${TARGET_TRIPLET}-rel + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel done") + + # configure debug + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_DEBUG_CFLAGS}") + set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_DEBUG_CXXFLAGS}") + set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_DEBUG_LDFLAGS}") + set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_DEBUG_CPPFLAGS}") + vcpkg_execute_required_process( + COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_DEBUG} ${_vcm_SOURCE_PATH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME config-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done") + +endfunction() diff --git a/scripts/cmake/vcpkg_configure_qmake.cmake b/scripts/cmake/vcpkg_configure_qmake.cmake new file mode 100644 index 000000000..f51a2f4fb --- /dev/null +++ b/scripts/cmake/vcpkg_configure_qmake.cmake @@ -0,0 +1,44 @@ +#.rst: +# .. command:: vcpkg_configure_qmake +# +# Configure a qmake-based project. +# It is assume that the qmake project CONFIG variable is +# "debug_and_release" (the default value on Windows, see [1]). +# Using this option, only one Makefile for building both Release and Debug +# libraries is generated, that then can be run using the vcpkg_install_qmake +# command. +# +# :: +# vcpkg_configure_qmake(SOURCE_PATH <pro_file_path> +# [OPTIONS arg1 [arg2 ...]] +# ) +# +# ``PROJECT_PATH`` +# The path to the *.pro qmake project file. +# ``OPTIONS`` +# The options passed to qmake. +# +# [1] : http://doc.qt.io/qt-5/qmake-variable-reference.html + +function(vcpkg_configure_qmake) + cmake_parse_arguments(_csc "" "SOURCE_PATH" "OPTIONS" ${ARGN}) + + # Find qmake exectuable + find_program(QMAKE_COMMAND NAMES qmake) + + if(NOT QMAKE_COMMAND) + BUILD_ERROR("vcpkg_configure_qmake: impossible to find qmake.") + endif() + + # Cleanup build directories + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}) + + message(STATUS "Configuring ${TARGET_TRIPLET}") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}) + vcpkg_execute_required_process( + COMMAND ${QMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET} + LOGNAME config-${TARGET_TRIPLET} + ) + message(STATUS "Configuring ${TARGET_TRIPLET} done") +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_copy_pdbs.cmake b/scripts/cmake/vcpkg_copy_pdbs.cmake index b99649d59..61ad97728 100644 --- a/scripts/cmake/vcpkg_copy_pdbs.cmake +++ b/scripts/cmake/vcpkg_copy_pdbs.cmake @@ -1,4 +1,5 @@ function(vcpkg_copy_pdbs) + function(merge_filelist OUTVAR INVAR) set(MSG "") foreach(VAR ${${INVAR}}) @@ -7,32 +8,39 @@ function(vcpkg_copy_pdbs) set(${OUTVAR} ${MSG} PARENT_SCOPE) endfunction() - file(GLOB_RECURSE DLLS ${CURRENT_PACKAGES_DIR}/bin/*.dll ${CURRENT_PACKAGES_DIR}/debug/bin/*.dll) - - set(DLLS_WITHOUT_MATCHING_PDBS) - - foreach(DLL ${DLLS}) - execute_process(COMMAND dumpbin /PDBPATH ${DLL} - COMMAND findstr PDB - OUTPUT_VARIABLE PDB_LINE - ERROR_QUIET - RESULT_VARIABLE error_code - ) - - if(NOT error_code AND PDB_LINE MATCHES "PDB file found at") - string(REGEX MATCH '.*' PDB_PATH ${PDB_LINE}) # Extract the path which is in single quotes - string(REPLACE ' "" PDB_PATH ${PDB_PATH}) # Remove single quotes - get_filename_component(DLL_DIR ${DLL} DIRECTORY) - file(COPY ${PDB_PATH} DESTINATION ${DLL_DIR}) - else() - list(APPEND DLLS_WITHOUT_MATCHING_PDBS ${DLL}) - endif() - endforeach() + if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + file(GLOB_RECURSE DLLS ${CURRENT_PACKAGES_DIR}/bin/*.dll ${CURRENT_PACKAGES_DIR}/debug/bin/*.dll) + + set(DLLS_WITHOUT_MATCHING_PDBS) + + set(PREVIOUS_VSLANG $ENV{VSLANG}) + set(ENV{VSLANG} 1033) + + foreach(DLL ${DLLS}) + execute_process(COMMAND dumpbin /PDBPATH ${DLL} + COMMAND findstr PDB + OUTPUT_VARIABLE PDB_LINE + ERROR_QUIET + RESULT_VARIABLE error_code + ) - list(LENGTH DLLS_WITHOUT_MATCHING_PDBS UNMATCHED_DLLS_LENGTH) - if(UNMATCHED_DLLS_LENGTH GREATER 0) - merge_filelist(MSG DLLS_WITHOUT_MATCHING_PDBS) - message(STATUS "Warning: Could not find a matching pdb file for:\n${MSG}") + if(NOT error_code AND PDB_LINE MATCHES "PDB file found at") + string(REGEX MATCH '.*' PDB_PATH ${PDB_LINE}) # Extract the path which is in single quotes + string(REPLACE ' "" PDB_PATH ${PDB_PATH}) # Remove single quotes + get_filename_component(DLL_DIR ${DLL} DIRECTORY) + file(COPY ${PDB_PATH} DESTINATION ${DLL_DIR}) + else() + list(APPEND DLLS_WITHOUT_MATCHING_PDBS ${DLL}) + endif() + endforeach() + + set(ENV{VSLANG} ${PREVIOUS_VSLANG}) + + list(LENGTH DLLS_WITHOUT_MATCHING_PDBS UNMATCHED_DLLS_LENGTH) + if(UNMATCHED_DLLS_LENGTH GREATER 0) + merge_filelist(MSG DLLS_WITHOUT_MATCHING_PDBS) + message(STATUS "Warning: Could not find a matching pdb file for:\n${MSG}") + endif() endif() endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_copy_tool_dependencies.cmake b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake new file mode 100644 index 000000000..432e3c12a --- /dev/null +++ b/scripts/cmake/vcpkg_copy_tool_dependencies.cmake @@ -0,0 +1,16 @@ +# Copy dlls for all tools in TOOL_DIR + +function(vcpkg_copy_tool_dependencies TOOL_DIR) + macro(search_for_dependencies PATH_TO_SEARCH) + file(GLOB TOOLS ${TOOL_DIR}/*.exe ${TOOL_DIR}/*.dll) + foreach(TOOL ${TOOLS}) + execute_process(COMMAND powershell -noprofile -executionpolicy UnRestricted -nologo + -file ${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/applocal.ps1 + -targetBinary ${TOOL} + -installedDir ${PATH_TO_SEARCH} + OUTPUT_VARIABLE OUT) + endforeach() + endmacro() + search_for_dependencies(${CURRENT_PACKAGES_DIR}/bin) + search_for_dependencies(${CURRENT_INSTALLED_DIR}/bin) +endfunction() diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake index 3145c8851..44b562573 100644 --- a/scripts/cmake/vcpkg_download_distfile.cmake +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -1,20 +1,52 @@ -# Usage: vcpkg_download_distfile(<VAR> URL <http://...> FILENAME <output.zip> SHA512 <5981de...>) +# Usage: vcpkg_download_distfile(<VAR> URLS <http://mainUrl> <http://mirror1> <http://mirror2> FILENAME <output.zip> SHA512 <5981de...>) function(vcpkg_download_distfile VAR) - set(oneValueArgs URL FILENAME SHA512) - cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "" ${ARGN}) + set(oneValueArgs FILENAME SHA512) + set(multipleValuesArgs URLS) + cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) + set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) - if(EXISTS ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) - message(STATUS "Using cached ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}") - file(SHA512 ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} FILE_HASH) - if(NOT FILE_HASH STREQUAL "${vcpkg_download_distfile_SHA512}") + function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE) + message(STATUS "Testing integrity of ${FILE_KIND}...") + file(SHA512 ${downloaded_file_path} FILE_HASH) + if(NOT "${FILE_HASH}" STREQUAL "${vcpkg_download_distfile_SHA512}") message(FATAL_ERROR - "File does not have expected hash: ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}\n" - " '${FILE_HASH}' <> '${vcpkg_download_distfile_SHA512}'\n" - "Please delete the file and try again if this file should be downloaded again.") + "\nFile does not have expected hash:\n" + " File path: [ ${downloaded_file_path} ]\n" + " Expected hash: [ ${vcpkg_download_distfile_SHA512} ]\n" + " Actual hash: [ ${FILE_HASH} ]\n" + "${CUSTOM_ERROR_ADVICE}\n") endif() + message(STATUS "Testing integrity of ${FILE_KIND}... OK") + endfunction() + + if(EXISTS ${downloaded_file_path}) + message(STATUS "Using cached ${downloaded_file_path}") + test_hash("cached file" "Please delete the file and retry if this file should be downloaded again.") else() - message(STATUS "Downloading ${vcpkg_download_distfile_URL}") - file(DOWNLOAD ${vcpkg_download_distfile_URL} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} EXPECTED_HASH SHA512=${vcpkg_download_distfile_SHA512}) + # Tries to download the file. + foreach(url IN LISTS vcpkg_download_distfile_URLS) + message(STATUS "Downloading ${url}...") + file(DOWNLOAD ${url} ${downloaded_file_path} STATUS download_status) + list(GET download_status 0 status_code) + if (NOT "${status_code}" STREQUAL "0") + message(STATUS "Downloading ${url}... Failed. Status: ${download_status}") + file(REMOVE ${downloaded_file_path}) + set(download_success 0) + else() + message(STATUS "Downloading ${url}... OK") + set(download_success 1) + break() + endif() + endforeach(url) + + if (NOT ${download_success}) + message(FATAL_ERROR + "\n" + " Failed to download file.\n" + " Add mirrors or submit an issue at https://github.com/Microsoft/vcpkg/issues\n") + else() + test_hash("downloaded file" "The file may be corrupted.") + endif() endif() - set(${VAR} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} PARENT_SCOPE) + set(${VAR} ${downloaded_file_path} PARENT_SCOPE) endfunction() diff --git a/scripts/cmake/vcpkg_execute_required_process.cmake b/scripts/cmake/vcpkg_execute_required_process.cmake index bd6e56f7b..7feff08b2 100644 --- a/scripts/cmake/vcpkg_execute_required_process.cmake +++ b/scripts/cmake/vcpkg_execute_required_process.cmake @@ -12,9 +12,9 @@ function(vcpkg_execute_required_process) file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}" NATIVE_BUILDTREES_DIR) if(error_code) message(FATAL_ERROR - "Command failed: ${vcpkg_execute_required_process_COMMAND}\n" - "Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n" - "See logs for more information:\n" + " Command failed: ${vcpkg_execute_required_process_COMMAND}\n" + " Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n" + " See logs for more information:\n" " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-out.log\n" " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-err.log\n") endif() diff --git a/scripts/cmake/vcpkg_execute_required_process_repeat.cmake b/scripts/cmake/vcpkg_execute_required_process_repeat.cmake new file mode 100644 index 000000000..d6fba132d --- /dev/null +++ b/scripts/cmake/vcpkg_execute_required_process_repeat.cmake @@ -0,0 +1,28 @@ +# Usage: vcpkg_execute_required_process_repeat(COUNT <num> COMMAND <cmd> [<args>...] WORKING_DIRECTORY </path/to/dir> LOGNAME <my_log_name>) +function(vcpkg_execute_required_process_repeat) + cmake_parse_arguments(vcpkg_execute_required_process_repeat "" "COUNT;WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN}) + #debug_message("vcpkg_execute_required_process_repeat(${vcpkg_execute_required_process_repeat_COMMAND})") + foreach(loop_count RANGE ${vcpkg_execute_required_process_repeat_COUNT}) + execute_process( + COMMAND ${vcpkg_execute_required_process_repeat_COMMAND} + OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_repeat_LOGNAME}-out.log + ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_repeat_LOGNAME}-err.log + RESULT_VARIABLE error_code + WORKING_DIRECTORY ${vcpkg_execute_required_process_repeat_WORKING_DIRECTORY}) + #debug_message("error_code=${error_code}") + file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}" NATIVE_BUILDTREES_DIR) + if(NOT error_code) + set(SUCCESSFUL_EXECUTION TRUE) + break() + endif() + endforeach(loop_count) + if (NOT ${SUCCESSFUL_EXECUTION}) + message(FATAL_ERROR + " Command failed: ${vcpkg_execute_required_process_repeat_COMMAND}\n" + " Working Directory: ${vcpkg_execute_required_process_repeat_WORKING_DIRECTORY}\n" + " See logs for more information:\n" + " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_repeat_LOGNAME}-out.log\n" + " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_repeat_LOGNAME}-err.log\n" + ) + endif() +endfunction() diff --git a/scripts/cmake/vcpkg_extract_source_archive.cmake b/scripts/cmake/vcpkg_extract_source_archive.cmake index 7e4efde07..70c9fe06b 100644 --- a/scripts/cmake/vcpkg_extract_source_archive.cmake +++ b/scripts/cmake/vcpkg_extract_source_archive.cmake @@ -1,16 +1,22 @@ include(vcpkg_execute_required_process) function(vcpkg_extract_source_archive ARCHIVE) + if(NOT ARGC EQUAL 2) + set(WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) + else() + set(WORKING_DIRECTORY ${ARGV1}) + endif() + get_filename_component(ARCHIVE_FILENAME ${ARCHIVE} NAME) - if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src/${ARCHIVE_FILENAME}.extracted) + if(NOT EXISTS ${WORKING_DIRECTORY}/${ARCHIVE_FILENAME}.extracted) message(STATUS "Extracting source ${ARCHIVE}") - file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) + file(MAKE_DIRECTORY ${WORKING_DIRECTORY}) vcpkg_execute_required_process( COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src + WORKING_DIRECTORY ${WORKING_DIRECTORY} LOGNAME extract ) - file(WRITE ${CURRENT_BUILDTREES_DIR}/src/${ARCHIVE_FILENAME}.extracted) + file(WRITE ${WORKING_DIRECTORY}/${ARCHIVE_FILENAME}.extracted) endif() message(STATUS "Extracting done") endfunction() diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index 8f974240f..d6bd34b21 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -4,19 +4,24 @@ function(vcpkg_find_acquire_program VAR) endif() unset(NOEXTRACT) + unset(SUBDIR) + unset(REQUIRED_INTERPRETER) + + vcpkg_get_program_files_platform_bitness(PROGRAM_FILES_PLATFORM_BITNESS) + vcpkg_get_program_files_32_bit(PROGRAM_FILES_32_BIT) if(VAR MATCHES "PERL") set(PROGNAME perl) set(PATHS ${DOWNLOADS}/tools/perl/perl/bin) - set(URL "http://strawberryperl.com/download/5.20.2.1/strawberry-perl-5.20.2.1-64bit-portable.zip") - set(ARCHIVE "strawberry-perl-5.20.2.1-64bit-portable.zip") - set(HASH 6e14e5580e52da5d35f29b67a52ef9db0e021af1575b4bbd84ebdbf18580522287890bdc21c0d21ddc1b2529d888f8e159dcaa017a3ff06d8fd23d16901bcc8b) + set(URL "http://strawberryperl.com/download/5.24.1.1/strawberry-perl-5.24.1.1-32bit-portable.zip") + set(ARCHIVE "strawberry-perl-5.24.1.1-32bit-portable.zip") + set(HASH a6e685ea24376f50db5f06c5b46075f1d3be25168fa1f27fa9b02e2ac017826cee62a2b43562f9b6c989337a231ba914416c110075457764de2d11f99d5e0f26) elseif(VAR MATCHES "NASM") set(PROGNAME nasm) - set(PATHS ${DOWNLOADS}/tools/nasm/nasm-2.11.08) - set(URL "http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/win32/nasm-2.11.08-win32.zip") - set(ARCHIVE "nasm-2.11.08-win32.zip") - set(HASH cd80b540530d3995d15dc636e97673f1d34f471baadf1dac993165232c61efefe7f8ec10625f8f718fc89f0dd3dcb6a4595e0cf40c5fd7cbac1b71672b644d2d) + set(PATHS ${DOWNLOADS}/tools/nasm/nasm-2.12.02) + set(URL "http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/win32/nasm-2.12.02-win32.zip") + set(ARCHIVE "nasm-2.12.02-win32.zip") + set(HASH df7aaba094e17832688c88993997612a2e2c96cc3dc14ca3e8347b44c7762115f5a7fc6d7f20be402553aaa4c9e43ddfcf6228f581cfe89289bae550de151b36) elseif(VAR MATCHES "YASM") set(PROGNAME yasm) set(PATHS ${DOWNLOADS}/tools/yasm) @@ -24,27 +29,103 @@ function(vcpkg_find_acquire_program VAR) set(ARCHIVE "yasm.exe") set(NOEXTRACT ON) set(HASH 850b26be5bbbdaeaf45ac39dd27f69f1a85e600c35afbd16b9f621396b3c7a19863ea3ff316b025b578fce0a8280eef2203306a2b3e46ee1389abb65313fb720) + elseif(VAR MATCHES "PYTHON3") + set(PROGNAME python) + set(PATHS ${DOWNLOADS}/tools/python) + set(URL "https://www.python.org/ftp/python/3.5.3/python-3.5.3-embed-win32.zip") + set(ARCHIVE "python-3.5.3-embed-win32.zip") + set(HASH c8cfdc09d052dc27e4380e8e4bf0d32a4c0def7e03896c1fa6cabc26dde78bb74dbb04e3673cc36e3e307d65a1ef284d69174f0cc80008c83bc6178f192ac5cf) + elseif(VAR MATCHES "PYTHON2") + find_program(PYTHON2 NAMES python2 python PATHS C:/python27 ENV PYTHON) + if(NOT PYTHON2 MATCHES "NOTFOUND") + execute_process( + COMMAND ${PYTHON2} --version + OUTPUT_VARIABLE PYTHON_VER_CHECK_OUT + ERROR_VARIABLE PYTHON_VER_CHECK_ERR + ) + set(PYTHON_VER_CHECK "${PYTHON_VER_CHECK_OUT}${PYTHON_VER_CHECK_ERR}") + debug_message("PYTHON_VER_CHECK=${PYTHON_VER_CHECK}") + if(NOT PYTHON_VER_CHECK MATCHES "Python 2.7") + set(PYTHON2 PYTHON2-NOTFOUND) + find_program(PYTHON2 NAMES python2 python PATHS C:/python27 ENV PYTHON NO_SYSTEM_ENVIRONMENT_PATH) + endif() + endif() + if(PYTHON2 MATCHES "NOTFOUND") + message(FATAL_ERROR "Python 2.7 was not found in the path or by searching inside C:\\Python27.\n" + "There is no portable redistributable for Python 2.7, so you will need to install the MSI located at:\n" + " https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi\n" + ) + endif() + elseif(VAR MATCHES "JOM") + set(PROGNAME jom) + set(SUBDIR "jom-1.1.2") + set(PATHS ${DOWNLOADS}/tools/jom/${SUBDIR}) + set(URL "http://download.qt.io/official_releases/jom/jom_1_1_2.zip") + set(ARCHIVE "jom_1_1_2.zip") + set(HASH 830cd94ed6518fbe4604a0f5a3322671b4674b87d25a71349c745500d38e85c0fac4f6995242fc5521eb048e3966bb5ec2a96a06b041343ed8da9bba78124f34) + elseif(VAR MATCHES "7Z") + set(PROGNAME 7z) + set(PATHS "${PROGRAM_FILES_PLATFORM_BITNESS}/7-Zip" "${PROGRAM_FILES_32_BIT}/7-Zip" ${DOWNLOADS}/tools/7z/Files/7-Zip) + set(URL "http://7-zip.org/a/7z1604.msi") + set(ARCHIVE "7z1604.msi") + set(HASH 556f95f7566fe23704d136239e4cf5e2a26f939ab43b44145c91b70d031a088d553e5c21301f1242a2295dcde3143b356211f0108c68e65eef8572407618326d) + elseif(VAR MATCHES "NINJA") + set(PROGNAME ninja) + set(SUBDIR "ninja-1.7.2") + set(PATHS ${DOWNLOADS}/tools/ninja/${SUBDIR}) + set(URL "https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip") + set(ARCHIVE "ninja-win.zip") + set(HASH cccab9281b274c564f9ad77a2115be1f19be67d7b2ee14a55d1db1b27f3b68db8e76076e4f804b61eb8e573e26a8ecc9985675a8dcf03fd7a77b7f57234f1393) + elseif(VAR MATCHES "MESON") + set(PROGNAME meson) + set(REQUIRED_INTERPRETER PYTHON3) + set(SCRIPTNAME meson.py) + set(PATHS ${DOWNLOADS}/tools/meson/meson-0.38.1) + set(URL "https://github.com/mesonbuild/meson/archive/0.38.1.zip") + set(ARCHIVE "meson-0.38.1.zip") + set(HASH 89642b1d976af7e29e9ca2b1a378510ce286ebd90a8234e898f3dd9dd7151538fdfc61fba770681605dad843b77b344fee94f992f18328655669d5f603c7fee5) else() message(FATAL "unknown tool ${VAR} -- unable to acquire.") endif() - find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + macro(do_find) + if(NOT DEFINED REQUIRED_INTERPRETER) + find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + else() + vcpkg_find_acquire_program(${REQUIRED_INTERPRETER}) + find_file(SCIRPT ${SCRIPTNAME} PATHS ${PATHS}) + set(${VAR} ${${REQUIRED_INTERPRETER}} ${SCIRPT}) + endif() + endmacro() + + do_find() if(${VAR} MATCHES "-NOTFOUND") file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} EXPECTED_HASH SHA512=${HASH} SHOW_PROGRESS ) - file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}) + file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}) if(DEFINED NOEXTRACT) - file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}) + file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}) else() - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} - WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME} - ) + get_filename_component(ARCHIVE_EXTENSION ${ARCHIVE} EXT) + string(TOLOWER "${ARCHIVE_EXTENSION}" ARCHIVE_EXTENSION) + if(${ARCHIVE_EXTENSION} STREQUAL ".msi") + file(TO_NATIVE_PATH "${DOWNLOADS}/${ARCHIVE}" ARCHIVE_NATIVE_PATH) + file(TO_NATIVE_PATH "${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}" DESTINATION_NATIVE_PATH) + execute_process( + COMMAND msiexec /a ${ARCHIVE_NATIVE_PATH} /qn TARGETDIR=${DESTINATION_NATIVE_PATH} + WORKING_DIRECTORY ${DOWNLOADS} + ) + else() + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR} + ) + endif() endif() - find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + do_find() endif() set(${VAR} ${${VAR}} PARENT_SCOPE) diff --git a/scripts/cmake/vcpkg_get_program_files_32_bit.cmake b/scripts/cmake/vcpkg_get_program_files_32_bit.cmake new file mode 100644 index 000000000..6f4345473 --- /dev/null +++ b/scripts/cmake/vcpkg_get_program_files_32_bit.cmake @@ -0,0 +1,10 @@ +function(vcpkg_get_program_files_32_bit ret) + + set(ret_temp $ENV{ProgramFiles\(X86\)}) + if (NOT DEFINED ret_temp) + set(ret_temp $ENV{PROGRAMFILES}) + endif() + + set(${ret} ${ret_temp} PARENT_SCOPE) + +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_get_program_files_platform_bitness.cmake b/scripts/cmake/vcpkg_get_program_files_platform_bitness.cmake new file mode 100644 index 000000000..ed51b7401 --- /dev/null +++ b/scripts/cmake/vcpkg_get_program_files_platform_bitness.cmake @@ -0,0 +1,10 @@ +function(vcpkg_get_program_files_platform_bitness ret) + + set(ret_temp $ENV{ProgramW6432}) + if (NOT DEFINED ret_temp) + set(ret_temp $ENV{PROGRAMFILES}) + endif() + + set(${ret} ${ret_temp} PARENT_SCOPE) + +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_get_windows_sdk.cmake b/scripts/cmake/vcpkg_get_windows_sdk.cmake new file mode 100644 index 000000000..7a8014eb2 --- /dev/null +++ b/scripts/cmake/vcpkg_get_windows_sdk.cmake @@ -0,0 +1,15 @@ +function(vcpkg_get_windows_sdk ret) + execute_process( + COMMAND powershell.exe -ExecutionPolicy Bypass ${VCPKG_ROOT_DIR}/scripts/getWindowsSDK.ps1 + OUTPUT_VARIABLE WINDOWS_SDK + RESULT_VARIABLE error_code) + + if (${error_code}) + message(FATAL_ERROR "Could not find Windows SDK") + endif() + + # Remove trailing newline + string(REGEX REPLACE "\n$" "" WINDOWS_SDK "${WINDOWS_SDK}") + + set(${ret} ${WINDOWS_SDK} PARENT_SCOPE) +endfunction()
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_install_cmake.cmake b/scripts/cmake/vcpkg_install_cmake.cmake index 14f1bc94d..0ebff6961 100644 --- a/scripts/cmake/vcpkg_install_cmake.cmake +++ b/scripts/cmake/vcpkg_install_cmake.cmake @@ -1,7 +1,31 @@ function(vcpkg_install_cmake) + cmake_parse_arguments(_bc "MSVC_64_TOOLSET;DISABLE_PARALLEL" "" "" ${ARGN}) + + set(MSVC_EXTRA_ARGS + "/p:VCPkgLocalAppDataDisabled=true" + "/p:UseIntelMKL=No" + ) + + # Specifies the architecture of the toolset, NOT the architecture of the produced binary + # This can help libraries that cause the linker to run out of memory. + # https://support.microsoft.com/en-us/help/2891057/linker-fatal-error-lnk1102-out-of-memory + if (_bc_MSVC_64_TOOLSET) + list(APPEND MSVC_EXTRA_ARGS "/p:PreferredToolArchitecture=x64") + endif() + + if (NOT _bc_DISABLE_PARALLEL) + list(APPEND MSVC_EXTRA_ARGS "/m") + endif() + + if(EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/build.ninja) + set(BUILD_ARGS -v) # verbose output + else() + set(BUILD_ARGS ${MSVC_EXTRA_ARGS}) + endif() + message(STATUS "Package ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release --target install + COMMAND ${CMAKE_COMMAND} --build . --config Release --target install -- ${BUILD_ARGS} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME package-${TARGET_TRIPLET}-rel ) @@ -9,7 +33,7 @@ function(vcpkg_install_cmake) message(STATUS "Package ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install + COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install -- ${BUILD_ARGS} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME package-${TARGET_TRIPLET}-dbg ) diff --git a/scripts/cmake/vcpkg_install_meson.cmake b/scripts/cmake/vcpkg_install_meson.cmake new file mode 100644 index 000000000..f6d49288c --- /dev/null +++ b/scripts/cmake/vcpkg_install_meson.cmake @@ -0,0 +1,23 @@ +function(vcpkg_install_meson) + + vcpkg_find_acquire_program(NINJA) + + unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option + + message(STATUS "Package ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${NINJA} install -v + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME package-${TARGET_TRIPLET}-rel + ) + message(STATUS "Package ${TARGET_TRIPLET}-rel done") + + message(STATUS "Package ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${NINJA} install -v + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME package-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Package ${TARGET_TRIPLET}-dbg done") + +endfunction() diff --git a/scripts/doVcpkgRelease.ps1 b/scripts/doVcpkgRelease.ps1 deleted file mode 100644 index 3b3021286..000000000 --- a/scripts/doVcpkgRelease.ps1 +++ /dev/null @@ -1,85 +0,0 @@ -[CmdletBinding()] -param( - -) - -$version = git show HEAD:toolsrc/VERSION.txt -#Remove the quotes from the string -$version = $version.Substring(1, $version.length - 2) -$versionRegex = '^\d+\.\d+\.\d+$' -if (!($version -match $versionRegex)) -{ - throw [System.ArgumentException] ("Expected version in the form d.d.d but was " + $version) -} - -Write-Verbose("New version is " + $version) -$gitTagString = "v$version" - -# Intentionally doesn't have ^ (=starts with) to match remote tags as well -$matchingTags = git tag | Where-Object {$_ -match "$gitTagString$"} -if ($matchingTags.Length -gt 0) -{ - throw [System.ArgumentException] ("Git tag matches existing tags: " + $matchingTags) -} - -$gitHash = git rev-parse HEAD -Write-Verbose("Git hash is " + $gitHash) - -$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition -$vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root -$gitStartOfHash = $gitHash.substring(0,6) -$versionWithStartOfHash = "$version-$gitStartOfHash" -$buildPath = "$vcpkgRootDir\build-$versionWithStartOfHash" -$releasePath = "$vcpkgRootDir\release-$versionWithStartOfHash" -Write-Verbose("Build Path " + $buildPath) -Write-Verbose("Release Path " + $releasePath) - -# 0 is metrics disabled, 1 is metrics enabled -for ($disableMetrics = 0; $disableMetrics -le 1; $disableMetrics++) -{ - - if (!(Test-Path $buildPath)) - { - New-Item -ItemType directory -Path $buildPath -force | Out-Null - } - - if (!(Test-Path $releasePath)) - { - New-Item -ItemType directory -Path $releasePath -force | Out-Null - } - - # Partial checkout for building vcpkg - $dotGitDir = "$vcpkgRootDir\.git" - $workTreeForBuildOnly = "$buildPath" - $checkoutThisDirForBuildOnly1 = ".\scripts" # Must be relative to the root of the repository - $checkoutThisDirForBuildOnly2 = ".\toolsrc" # Must be relative to the root of the repository - Write-Verbose("Creating partial temporary checkout: $buildPath") - git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly1 - git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly2 - - & "$buildPath\scripts\bootstrap.ps1" -disableMetrics $disableMetrics - - # Full checkout which will be a zip along with the executables from the previous step - $workTree = "$releasePath" - $checkoutThisDir = ".\" # Must be relative to the root of the repository - Write-Verbose("Creating temporary checkout: $releasePath") - git --git-dir=$dotGitDir --work-tree=$workTree checkout $gitHash -f -q -- $checkoutThisDir - - Copy-Item $buildPath\vcpkg.exe $releasePath\vcpkg.exe | Out-Null - Copy-Item $buildPath\scripts\vcpkgmetricsuploader.exe $releasePath\scripts\vcpkgmetricsuploader.exe | Out-Null - - Write-Verbose("Archiving") - $outputArchive = "$vcpkgRootDir\vcpkg-$versionWithStartOfHash.zip" - if ($disableMetrics -ne 0) - { - $outputArchive = "$vcpkgRootDir\vcpkg-$versionWithStartOfHash-external.zip" - } - Compress-Archive -Path "$releasePath\*" -CompressionLevel Optimal -DestinationPath $outputArchive -Force | Out-Null - - Write-Verbose("Removing temporary checkouts: $releasePath") - Remove-Item -recurse $buildPath | Out-Null - Remove-Item -recurse $releasePath | Out-Null - - Write-Verbose("Redistributable archive is: $outputArchive") -} -git tag $gitTagString
\ No newline at end of file diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 2f3d992ba..3c98f7247 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -1,9 +1,15 @@ [CmdletBinding()] param( - [string]$Dependency + [string]$Dependency, + [ValidateNotNullOrEmpty()] + [string]$downloadPromptOverride = "0" ) -Import-Module BitsTransfer +$downloadPromptOverride_NO_OVERRIDE= 0 +$downloadPromptOverride_DO_NOT_PROMPT = 1 +$downloadPromptOverride_ALWAYS_PROMPT = 2 + +Import-Module BitsTransfer -Verbose:$false $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition $vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root @@ -12,9 +18,13 @@ $downloadsDir = "$vcpkgRootDir\downloads" function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { - function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription) + function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription, [string]$downloadPromptOverride) { - if ((Test-Path "$downloadsDir\AlwaysAllowEverything") -Or (Test-Path "$downloadsDir\AlwaysAllowDownloads")) + $do_not_prompt = ($downloadPromptOverride -eq $downloadPromptOverride_DO_NOT_PROMPT) -Or + (Test-Path "$downloadsDir\AlwaysAllowEverything") -Or + (Test-Path "$downloadsDir\AlwaysAllowDownloads") + + if (($downloadPromptOverride -ne $downloadPromptOverride_ALWAYS_PROMPT) -And $do_not_prompt) { return $true } @@ -51,13 +61,13 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { return } - + $title = "Download " + $Dependency $message = ("No suitable version of " + $Dependency + " was found (requires $requiredVersion or higher). Download portable version?") $yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally." - $noDescription = "Does not download " + $Dependency + "." - - $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription + $noDescription = "Does not download " + $Dependency + "." + + $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription $downloadPromptOverride if (!$userAllowedDownload) { throw [System.IO.FileNotFoundException] ("Could not detect suitable version of " + $Dependency + " and download not allowed") @@ -70,15 +80,29 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if ($Dependency -ne "git") # git fails with BITS { - Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction SilentlyContinue + try { + $WC = New-Object System.Net.WebClient + $ProxyAuth = !$WC.Proxy.IsBypassed($url) + If($ProxyAuth){ + $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential",$ProxyCred) + } + + Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop + } + catch [System.Exception] { + # If BITS fails for any reason, delete any potentially partially downloaded files and continue + if (Test-Path $downloadPath) + { + Remove-Item $downloadPath + } + } } - else + if (!(Test-Path $downloadPath)) { - if (!(Test-Path $downloadPath)) - { - Write-Host("Downloading $Dependency...") - (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath) - } + Write-Host("Downloading $Dependency...") + (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath) } } @@ -86,10 +110,10 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $ExtractionType_NO_EXTRACTION_REQUIRED = 0 $ExtractionType_ZIP = 1 $ExtractionType_SELF_EXTRACTING_7Z = 2 - - + + # Using this to wait for the execution to finish - function Invoke-Command() + function Invoke-Command() { param ( [string]$program = $(throw "Please specify a program" ), [string]$argumentString = "", @@ -99,7 +123,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $psi.FileName = $program $psi.Arguments = $argumentString $proc = [Diagnostics.Process]::Start($psi) - if ( $waitForExit ) + if ( $waitForExit ) { $proc.WaitForExit(); } @@ -107,8 +131,11 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) function Expand-ZIPFile($file, $destination) { - Write-Host($file) - Write-Host($destination) + if (!(Test-Path $destination)) + { + New-Item -ItemType Directory -Path $destination | Out-Null + } + $shell = new-object -com shell.application $zip = $shell.NameSpace($file) foreach($item in $zip.items()) @@ -120,42 +147,49 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if($Dependency -eq "cmake") { - $requiredVersion = "3.5.0" - $downloadVersion = "3.5.2" - $url = "https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.zip" - $downloadName = "cmake-3.5.2-win32-x86.zip" - $expectedDownloadedFileHash = "671073aee66b3480a564d0736792e40570a11e861bb34819bb7ae7858bbdfb80" - $executableFromDownload = "$downloadsDir\cmake-3.5.2-win32-x86\bin\cmake.exe" + $requiredVersion = "3.8.0" + $downloadVersion = "3.8.0" + $url = "https://cmake.org/files/v3.8/cmake-3.8.0-rc1-win32-x86.zip" + $downloadPath = "$downloadsDir\cmake-3.8.0-rc1-win32-x86.zip" + $expectedDownloadedFileHash = "ccdbd92fbfb548aa35a545e4e45ff19fd6d13c88c90370acdf940c3cf464e9c9" + $executableFromDownload = "$downloadsDir\cmake-3.8.0-rc1-win32-x86\bin\cmake.exe" $extractionType = $ExtractionType_ZIP + $extractionFolder = $downloadsDir } elseif($Dependency -eq "nuget") { - $requiredVersion = "1.0.0" - $downloadVersion = "3.4.3" - $url = "https://dist.nuget.org/win-x86-commandline/v3.4.3/nuget.exe" - $downloadName = "nuget.exe" - $expectedDownloadedFileHash = "3B1EA72943968D7AF6BACDB4F2F3A048A25AFD14564EF1D8B1C041FDB09EBB0A" - $executableFromDownload = "$downloadsDir\nuget.exe" + $requiredVersion = "3.3.0" + $downloadVersion = "3.5.0" + $url = "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe" + $downloadPath = "$downloadsDir\nuget-3.5.0\nuget.exe" + $expectedDownloadedFileHash = "399ec24c26ed54d6887cde61994bb3d1cada7956c1b19ff880f06f060c039918" + $executableFromDownload = $downloadPath $extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED } elseif($Dependency -eq "git") { $requiredVersion = "2.0.0" - $downloadVersion = "2.8.3" - $url = "https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/PortableGit-2.8.3-32-bit.7z.exe" # We choose the 32-bit version - $downloadName = "PortableGit-2.8.3-32-bit.7z.exe" - $expectedDownloadedFileHash = "DE52D070219E9C4EC1DB179F2ADBF4B760686C3180608F0382A1F8C7031E72AD" - # There is another copy of git.exe in PortableGit\bin. However, an installed version of git add the cmd dir to the PATH. - # Therefore, choosing the cmd dir here as well. - $executableFromDownload = "$downloadsDir\PortableGit\cmd\git.exe" - $extractionType = $ExtractionType_SELF_EXTRACTING_7Z + $downloadVersion = "2.11.1" + $url = "https://github.com/git-for-windows/git/releases/download/v2.11.1.windows.1/MinGit-2.11.1-32-bit.zip" # We choose the 32-bit version + $downloadPath = "$downloadsDir\MinGit-2.11.1-32-bit.zip" + $expectedDownloadedFileHash = "6ca79af09015625f350ef4ad74a75cfb001b340aec095b6963be9d45becb3bba" + # There is another copy of git.exe in MinGit\bin. However, an installed version of git add the cmd dir to the PATH. + # Therefore, choosing the cmd dir here as well. + $executableFromDownload = "$downloadsDir\MinGit-2.11.1-32-bit\cmd\git.exe" + $extractionType = $ExtractionType_ZIP + $extractionFolder = "$downloadsDir\MinGit-2.11.1-32-bit" } else { throw "Unknown program requested" } - $downloadPath = "$downloadsDir\$downloadName" + $downloadSubdir = Split-path $downloadPath -Parent + if (!(Test-Path $downloadSubdir)) + { + New-Item -ItemType Directory -Path $downloadSubdir | Out-Null + } + performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion #calculating the hash @@ -177,8 +211,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { if (-not (Test-Path $executableFromDownload)) # consider renaming the extraction folder to make sure the extraction finished { - # Expand-Archive $downloadPath -dest "$downloadsDir" -Force # Requires powershell 5+ - Expand-ZIPFile -File $downloadPath -Destination $downloadsDir + # Expand-Archive $downloadPath -dest "$extractionFolder" -Force # Requires powershell 5+ + Expand-ZIPFile -File $downloadPath -Destination $extractionFolder } } elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z) @@ -186,7 +220,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if (-not (Test-Path $executableFromDownload)) { Invoke-Command $downloadPath "-y" -waitForExit:$true - } + } } else { @@ -197,6 +231,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { throw [System.IO.FileNotFoundException] ("Could not detect or download " + $Dependency) } + + return $executableFromDownload } SelectProgram $Dependency
\ No newline at end of file diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 new file mode 100644 index 000000000..f1ef1ae6b --- /dev/null +++ b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 @@ -0,0 +1,164 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory=$False)] + [switch]$DisableVS2017 = $False, + + [Parameter(Mandatory=$False)] + [switch]$DisableVS2015 = $False +) + +if ($DisableVS2017 -and $DisableVS2015) +{ + throw "Both VS2015 and VS2017 were disabled." +} + +function New-MSBuildInstance() +{ + param ($msbuildExePath, $toolsetVersion) + + $instance = new-object PSObject + $instance | add-member -type NoteProperty -Name msbuildExePath -Value $msbuildExePath + $instance | add-member -type NoteProperty -Name toolsetVersion -Value $toolsetVersion + + return $instance +} + +Write-Verbose "Executing $($MyInvocation.MyCommand.Name) with DisableVS2017=$DisableVS2017, DisableVS2015=$DisableVS2015" +$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition + +$validInstances = New-Object System.Collections.ArrayList + +# VS2017 +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2017 instances..." +$VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 +Write-Verbose "VS2017 Candidates: $([system.String]::Join(',', $VisualStudio2017InstallationInstances))" +foreach ($instanceCandidate in $VisualStudio2017InstallationInstances) +{ + $VCFolder= "$instanceCandidate\VC\Tools\MSVC\" + + if (Test-Path $VCFolder) + { + $instance = New-MSBuildInstance "$instanceCandidate\MSBuild\15.0\Bin\MSBuild.exe" "v141" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null + } +} + +# VS2015 - in Program Files +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2015 in Program Files..." +$CandidateProgramFiles = $(& $scriptsDir\getProgramFiles32bit.ps1), $(& $scriptsDir\getProgramFilesPlatformBitness.ps1) +Write-Verbose "Program Files Candidate locations: $([system.String]::Join(',', $CandidateProgramFiles))" +foreach ($ProgramFiles in $CandidateProgramFiles) +{ + $clExe= "$ProgramFiles\Microsoft Visual Studio 14.0\VC\bin\cl.exe" + + if (!(Test-Path $clExe)) + { + Write-Verbose "$clExe - Not Found" + continue + } + + Write-Verbose "$clExe - Found" + $instance = New-MSBuildInstance "$ProgramFiles\MSBuild\14.0\Bin\MSBuild.exe" "v140" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null +} + +# VS2015 - through the registry +function NewCppRegistryPair() +{ + param ($visualStudioEntry, $msBuildEntry) + + $instance = new-object PSObject + $instance | add-member -type NoteProperty -Name visualStudioEntry -Value $visualStudioEntry + $instance | add-member -type NoteProperty -Name msBuildEntry -Value $msBuildEntry + + return $instance +} + +Write-Verbose "`n`n" +Write-Verbose "Checking for MSBuild from VS2015 through the registry..." + +$registryPairs = +$(NewCppRegistryPair "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\visualstudio\14.0" "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\msbuild\toolsversions\14.0"), +$(NewCppRegistryPair "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\visualstudio\14.0" "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\msbuild\toolsversions\14.0") + +foreach ($pair in $registryPairs) +{ + $vsEntry = $pair.visualStudioEntry + try + { + $VS14InstallDir = $(gp $vsEntry InstallDir -erroraction Stop | % { $_.InstallDir }) + Write-Verbose "$vsEntry - Found" + } + catch + { + Write-Verbose "$vsEntry - Not Found" + continue + } + + Write-Verbose "$VS14InstallDir - Obtained from registry" + # We want "${VS14InstallDir}..\..\VC\bin\cl.exe" + # Doing Split-path to avoid the ..\.. from appearing in the output + $clExePath = Split-path $VS14InstallDir -Parent + $clExePath = Split-path $clExePath -Parent + $clExePath = "$clExePath\VC\bin\cl.exe" + + if (!(Test-Path $clExePath)) + { + Write-Verbose "$clExePath - Not Found" + continue + } + + Write-Verbose "$clExePath - Found" + + $msbuildEntry = $pair.msBuildEntry + try + { + $MSBuild14 = $(gp $msbuildEntry MSBuildToolsPath -erroraction Stop | % { $_.MSBuildToolsPath }) + Write-Verbose "$msbuildEntry - Found" + } + catch + { + Write-Verbose "$msbuildEntry - Not Found" + continue + } + + Write-Verbose "${MSBuild14} - Obtained from registry" + $msbuildPath = "${MSBuild14}MSBuild.exe" + if (!(Test-Path $msbuildPath)) + { + Write-Verbose "$msbuildPath - Not Found" + continue + } + + $instance = New-MSBuildInstance $msbuildPath "v140" + Write-Verbose "Found $instance" + $validInstances.Add($instance) > $null +} + +Write-Verbose "`n`n`n" +Write-Verbose "The following MSBuild instances were found:" +foreach ($instance in $validInstances) +{ + Write-Verbose $instance +} + +# Selecting +foreach ($instance in $validInstances) +{ + if (!$DisableVS2017 -and $instance.toolsetVersion -eq "v141") + { + return $instance.msbuildExePath, $instance.toolsetVersion + } + + if (!$DisableVS2015 -and $instance.toolsetVersion -eq "v140") + { + return $instance.msbuildExePath, $instance.toolsetVersion + } +} + + +throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed."
\ No newline at end of file diff --git a/scripts/findFileRecursivelyUp.ps1 b/scripts/findFileRecursivelyUp.ps1 index 788adbf08..4b6409e8c 100644 --- a/scripts/findFileRecursivelyUp.ps1 +++ b/scripts/findFileRecursivelyUp.ps1 @@ -11,8 +11,8 @@ $currentDir = $startingDir while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename")) { - Write-Verbose "Examining: $currentDir" + Write-Verbose "Examining $currentDir for $filename" $currentDir = Split-path $currentDir -Parent } -Write-Verbose "Found: $currentDir" +Write-Verbose "Examining $currentDir for $filename - Found" return $currentDir
\ No newline at end of file diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 new file mode 100644 index 000000000..0f685c6a9 --- /dev/null +++ b/scripts/findVisualStudioInstallationInstances.ps1 @@ -0,0 +1,33 @@ +[CmdletBinding()] +param( + +) + +$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition +$vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root + +$downloadsDir = "$vcpkgRootDir\downloads" + +$nugetexe = & $scriptsDir\fetchDependency.ps1 "nuget" 1 +$nugetPackageDir = "$downloadsDir\nuget-packages" + +$SetupAPIVersion = "1.8.24" +$nugetOutput = & $nugetexe install Microsoft.VisualStudio.Setup.Configuration.Native -Version $SetupAPIVersion -OutputDirectory $nugetPackageDir -Source "https://api.nuget.org/v3/index.json" -nocache 2>&1 + +$SetupConsoleExe = "$nugetPackageDir\Microsoft.VisualStudio.Setup.Configuration.Native.$SetupAPIVersion\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Console.exe" + +if (!(Test-Path $SetupConsoleExe)) +{ + throw $nugetOutput +} + +$instances = & $SetupConsoleExe -nologo -value InstallationPath 2>&1 +$instanceCount = $instances.Length + +# The last item can be empty +if ($instanceCount -gt 0 -and $instances[$instanceCount - 1] -eq "") +{ + $instances = $instances[0..($instanceCount - 2)] +} + +return $instances diff --git a/scripts/getProgramFiles32bit.ps1 b/scripts/getProgramFiles32bit.ps1 new file mode 100644 index 000000000..6b71915b1 --- /dev/null +++ b/scripts/getProgramFiles32bit.ps1 @@ -0,0 +1,17 @@ +[CmdletBinding()] +param( + +) + +$out = ${env:PROGRAMFILES(X86)} +if ($out -eq $null) +{ + $out = ${env:PROGRAMFILES} +} + +if ($out -eq $null) +{ + throw "Could not find [Program Files 32-bit]" +} + +return $out
\ No newline at end of file diff --git a/scripts/getProgramFilesPlatformBitness.ps1 b/scripts/getProgramFilesPlatformBitness.ps1 new file mode 100644 index 000000000..2be4c1137 --- /dev/null +++ b/scripts/getProgramFilesPlatformBitness.ps1 @@ -0,0 +1,17 @@ +[CmdletBinding()] +param( + +) + +$out = ${env:ProgramW6432} +if ($out -eq $null) +{ + $out = ${env:PROGRAMFILES} +} + +if ($out -eq $null) +{ + throw "Could not find [Program Files Platform Bitness]" +} + +return $out
\ No newline at end of file diff --git a/scripts/getWindowsSDK.ps1 b/scripts/getWindowsSDK.ps1 new file mode 100644 index 000000000..90ca1b06b --- /dev/null +++ b/scripts/getWindowsSDK.ps1 @@ -0,0 +1,94 @@ +[CmdletBinding()] +param( + [Parameter(Mandatory=$False)] + [switch]$DisableWin10SDK = $False, + + [Parameter(Mandatory=$False)] + [switch]$DisableWin81SDK = $False +) + +if ($DisableWin10SDK -and $DisableWin81SDK) +{ + throw "Both Win10SDK and Win81SDK were disabled." +} + +Write-Verbose "Executing $($MyInvocation.MyCommand.Name)" +$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition + +$validInstances = New-Object System.Collections.ArrayList + +$CandidateProgramFiles = $(& $scriptsDir\getProgramFiles32bit.ps1), $(& $scriptsDir\getProgramFilesPlatformBitness.ps1) +Write-Verbose "Program Files Candidate locations: $([system.String]::Join(',', $CandidateProgramFiles))" + +# Windows 10 SDK +Write-Verbose "`n" +Write-Verbose "Looking for Windows 10 SDK" +foreach ($ProgramFiles in $CandidateProgramFiles) +{ + $folder = "$ProgramFiles\Windows Kits\10\Include" + if (!(Test-Path $folder)) + { + Write-Verbose "$folder - Not Found" + continue + } + + Write-Verbose "$folder - Found" + $win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object) + [array]::Reverse($win10sdkVersions) # Newest SDK first + + foreach ($win10sdkV in $win10sdkVersions) + { + $windowsheader = "$folder\$win10sdkV\um\windows.h" + if (!(Test-Path $windowsheader)) + { + Write-Verbose "$windowsheader - Not Found" + continue + } + + Write-Verbose "$windowsheader - Found" + $win10sdkVersionString = $win10sdkV.ToString() + Write-Verbose "Found $win10sdkVersionString" + $validInstances.Add($win10sdkVersionString) > $null + } +} + +# Windows 8.1 SDK +Write-Verbose "`n" +Write-Verbose "Looking for Windows 8.1 SDK" +foreach ($ProgramFiles in $CandidateProgramFiles) +{ + $folder = "$ProgramFiles\Windows Kits\8.1\Include" + if (!(Test-Path $folder)) + { + Write-Verbose "$folder - Not Found" + continue + } + + Write-Verbose "$folder - Found" + $win81sdkVersionString = "8.1" + Write-Verbose "Found $win81sdkVersionString" + $validInstances.Add($win81sdkVersionString) > $null +} + +Write-Verbose "`n`n`n" +Write-Verbose "The following Windows SDKs were found:" +foreach ($instance in $validInstances) +{ + Write-Verbose $instance +} + +# Selecting +foreach ($instance in $validInstances) +{ + if (!$DisableWin10SDK -and $instance -match "10.") + { + return $instance + } + + if (!$DisableWin81SDK -and $instance -match "8.1") + { + return $instance + } +} + +throw "Could not detect a Windows SDK / TargetPlatformVersion"
\ No newline at end of file diff --git a/scripts/ports.cmake b/scripts/ports.cmake index eeb7b254c..e83b83d88 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -1,5 +1,11 @@ cmake_minimum_required(VERSION 3.5) +macro(debug_message) + if(DEFINED PORT_DEBUG AND PORT_DEBUG) + message(STATUS "[DEBUG] ${ARGN}") + endif() +endmacro() + #Detect .vcpkg-root to figure VCPKG_ROOT_DIR SET(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR}) while(IS_DIRECTORY ${VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root") @@ -13,14 +19,6 @@ endwhile() set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE}) -string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) -string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) - -if(NOT EXISTS ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) - message(FATAL_ERROR "Unsupported target triplet. Toolchain file does not exist: ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake") -endif() - -set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake) set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages") set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools") @@ -32,37 +30,15 @@ if(PORT) set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET}) endif() -macro(debug_message) - if(DEFINED PORT_DEBUG AND PORT_DEBUG) - message(STATUS "[DEBUG] ${ARGN}") - endif() -endmacro() -if(CMD MATCHES "^SCAFFOLD$") - if(EXISTS ports/${PORT}/portfile.cmake) - message(FATAL_ERROR "Portfile already exists: '${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake'") - endif() - if(NOT FILENAME) - get_filename_component(FILENAME "${URL}" NAME) - endif() - string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME}) - if(EXISTS ${DOWNLOADS}/${FILENAME}) - message(STATUS "Using pre-downloaded: ${DOWNLOADS}/${FILENAME}") - message(STATUS "If this is not desired, delete the file and ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") - else() - include(vcpkg_download_distfile) - file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) - if(NOT error_code MATCHES "0;") - message(FATAL_ERROR "Error downloading file: ${error_code}") - endif() - endif() - file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512) +if(CMD MATCHES "^BUILD$") + string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) - file(MAKE_DIRECTORY ports/${PORT}) - configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY) + set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) + if(NOT EXISTS ${CMAKE_TRIPLET_FILE}) + message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}") + endif() - message(STATUS "Generated portfile: ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") -elseif(CMD MATCHES "^BUILD$") if(NOT DEFINED CURRENT_PORT_DIR) message(FATAL_ERROR "CURRENT_PORT_DIR was not defined") endif() @@ -93,5 +69,50 @@ elseif(CMD MATCHES "^BUILD$") endif() file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR}) + include(${CMAKE_TRIPLET_FILE}) include(${CURRENT_PORT_DIR}/portfile.cmake) + + set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO) + file(WRITE ${BUILD_INFO_FILE_PATH} "CRTLinkage: ${VCPKG_CRT_LINKAGE}\n") + file(APPEND ${BUILD_INFO_FILE_PATH} "LibraryLinkage: ${VCPKG_LIBRARY_LINKAGE}\n") + + if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_LIBS) + file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutLIBs: ${VCPKG_POLICY_DLLS_WITHOUT_LIBS}\n") + endif() + if (DEFINED VCPKG_POLICY_EMPTY_PACKAGE) + file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyPackage: ${VCPKG_POLICY_EMPTY_PACKAGE}\n") + endif() + if (DEFINED VCPKG_POLICY_ONLY_RELEASE_CRT) + file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyOnlyReleaseCRT: ${VCPKG_POLICY_ONLY_RELEASE_CRT}\n") + endif() +elseif(CMD MATCHES "^CREATE$") + file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR) + file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS) + if(EXISTS ports/${PORT}/portfile.cmake) + message(FATAL_ERROR "Portfile already exists: '${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake'") + endif() + if(NOT FILENAME) + get_filename_component(FILENAME "${URL}" NAME) + endif() + string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME}) + if(EXISTS ${DOWNLOADS}/${FILENAME}) + message(STATUS "Using pre-downloaded: ${NATIVE_DOWNLOADS}\\${FILENAME}") + message(STATUS "If this is not desired, delete the file and ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}") + else() + include(vcpkg_download_distfile) + file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) + if(NOT error_code MATCHES "0;") + message(FATAL_ERROR "Error downloading file: ${error_code}") + endif() + endif() + file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512) + + file(MAKE_DIRECTORY ports/${PORT}) + configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY) + configure_file(scripts/templates/CONTROL.in ports/${PORT}/CONTROL @ONLY) + + message(STATUS "Generated portfile: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake") + message(STATUS "Generated CONTROL: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\CONTROL") + message(STATUS "To launch an editor for these new files, run") + message(STATUS " vcpkg edit ${PORT}") endif() diff --git a/scripts/templates/CONTROL.in b/scripts/templates/CONTROL.in new file mode 100644 index 000000000..c5b706861 --- /dev/null +++ b/scripts/templates/CONTROL.in @@ -0,0 +1,3 @@ +Source: @PORT@ +Version: +Description:
\ No newline at end of file diff --git a/scripts/templates/portfile.in.cmake b/scripts/templates/portfile.in.cmake index 99a3ac3e8..ef72431ff 100644 --- a/scripts/templates/portfile.in.cmake +++ b/scripts/templates/portfile.in.cmake @@ -1,21 +1,30 @@ +# Common Ambient Variables: +# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg> +# TARGET_TRIPLET is the current triplet (x86-windows, etc) +# PORT is the current port name (zlib, etc) +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# + include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@) vcpkg_download_distfile(ARCHIVE - URL "@URL@" + URLS "@URL@" FILENAME "@FILENAME@" SHA512 @SHA512@ ) vcpkg_extract_source_archive(${ARCHIVE}) vcpkg_configure_cmake( - SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@ + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA # Disable this option if project cannot be built with Ninja # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 # OPTIONS_RELEASE -DOPTIMIZE=1 # OPTIONS_DEBUG -DDEBUGGABLE=1 ) -vcpkg_build_cmake() vcpkg_install_cmake() # Handle copyright -#file(COPY ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/@PORT@) +#file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/@PORT@) #file(RENAME ${CURRENT_PACKAGES_DIR}/share/@PORT@/LICENSE ${CURRENT_PACKAGES_DIR}/share/@PORT@/copyright)
\ No newline at end of file |
