install depends via vcpkg on Windows

This commit is contained in:
yuangongji
2020-03-07 15:00:28 +08:00
parent cc1098998f
commit b4d28c3d9d

View File

@@ -266,69 +266,44 @@ jobs:
pattern: [0, 1, 2, 3]
steps:
- uses: actions/checkout@v1
- name: Cache dependencies
id: cache-depends
uses: actions/cache@v1
- name: Cache vcpkg
id: cache-vcpkg
uses: actions/cache@v1.0.3
with:
path: third_party
key: ${{ runner.os }}-depends
path: C:/vcpkg/installed/x64-windows
key: ${{ runner.os }}-vcpkg
- name: Build dependencies
if: steps.cache-depends.outputs.cache-hit != 'true'
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: powershell
run: |
$CUR=(Get-Location).Path
Invoke-WebRequest -Uri https://github.com/google/googletest/archive/release-1.7.0.zip -OutFile googletest-release-1.7.0.zip
7z x googletest-release-1.7.0.zip
cd googletest-release-1.7.0
md build
cd build
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
cmake --build . --config Release
New-Item -ItemType Directory -Path "$CUR\third_party\googletest\lib"
Copy-Item "Release\*" -Destination "$CUR\third_party\googletest\lib"
Copy-Item -Path "..\include" -Destination "$CUR\third_party\googletest" -Recurse
cd ..
cd ..
Invoke-WebRequest -Uri http://zlib.net/zlib-1.2.11.tar.gz -OutFile zlib-1.2.11.tar.gz
7z x zlib-1.2.11.tar.gz
7z x zlib-1.2.11.tar
cd zlib-1.2.11
md build
cd build
cmake -DCMAKE_INSTALL_PREFIX="$CUR\third_party\zlib" ..
cmake --build . --config Release
New-Item -ItemType Directory -Path "$CUR\third_party\zlib\lib"
Copy-Item "Release\*" -Destination "$CUR\third_party\zlib\lib"
Copy-Item "..\zlib.h" -Destination "$CUR\third_party\zlib"
Copy-Item zconf.h -Destination "$CUR\third_party\zlib"
vcpkg install gtest:x64-windows
vcpkg install zlib:x64-windows
- name: Build and test
shell: powershell
run: |
if (${{ matrix.pattern }} -eq 0) {
$CPP11="-DMSGPACK_CXX11=""OFF"""
$BOOST="-DMSGPACK_BOOST=""OFF"""
$CPP11="-DMSGPACK_CXX11=OFF"
$BOOST="-DMSGPACK_BOOST=OFF"
}
if (${{ matrix.pattern }} -eq 1) {
$CPP11="-DMSGPACK_CXX11=""OFF"""
$BOOST="-DMSGPACK_BOOST=""ON"""
$CPP11="-DMSGPACK_CXX11=OFF"
$BOOST="-DMSGPACK_BOOST=ON"
}
if (${{ matrix.pattern }} -eq 2) {
$CPP11="-DMSGPACK_CXX11=""ON"""
$BOOST="-DMSGPACK_BOOST=""OFF"""
$CPP11="-DMSGPACK_CXX11=ON"
$BOOST="-DMSGPACK_BOOST=OFF"
}
if (${{ matrix.pattern }} -eq 3) {
$CPP11="-DMSGPACK_CXX11=""ON"""
$BOOST="-DMSGPACK_BOOST=""ON"""
$CPP11="-DMSGPACK_CXX11=ON"
$BOOST="-DMSGPACK_BOOST=ON"
}
$CUR=(Get-Location).Path
md build
cd build
echo $env:BOOST_ROOT
$env:BOOST_ROOT="$env:Boost_ROOT"
cmake -DBOOST_ROOT="$env:BOOST_ROOT" $CPP11 $BOOST $X3_PARSE -DGTEST_LIBRARY="$CUR\third_party\googletest\lib\gtest.lib" -DGTEST_MAIN_LIBRARY="$CUR\third_party\googletest\lib\gtest_main.lib" -DGTEST_INCLUDE_DIR="$CUR\third_party\googletest\include" -DZLIB_LIBRARY="$CUR\third_party\zlib\lib\zlib.lib" -DZLIB_INCLUDE_DIR="$CUR\third_party\zlib" -DCMAKE_CXX_FLAGS="/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" $CPP11 $BOOST "-DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING" ..
cmake --build . --config Release
$env:PATH="$env:PATH;$CUR\third_party\googletest\lib;$CUR\third_party\zlib\lib;$CUR\build\Release"
$pathbak="$env:PATH"
$env:PATH="C:\vcpkg\installed\x64-windows\bin;$CUR\build\Release;$pathbak"
ctest -V
$env:PATH=$pathbak