Use vcpkg manifest and cmake presets

Manifest is a convenient way to automatically
install dependencies. Since we have to support
both OpenSSL 1.1.1 (for OpenVPN 2.5) and OpenSSL 3
(for coming OpenVPN 2.6) and manifest file name
is hardcoded, we create two manifests and put them
into different directories.

To simplify build process, define configuration presets
for arch (x86/x64/arm64), debug/release and oss1.1.1/ossl3.

This way building is greatly simplified:

  cmake -S . --preset x64-debug-ossl3
  cmake --build --preset x64-debug-ossl3

Update GitHub Actions script accordingly.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
pull/500/head
Lev Stipakov 2022-05-09 13:56:37 +03:00 committed by Samuli Seppänen
parent 79f5cb91c6
commit b6f26818a9
6 changed files with 224 additions and 40 deletions

View File

@ -6,60 +6,37 @@ jobs:
msvc: msvc:
strategy: strategy:
matrix: matrix:
arch: [x86, amd64, amd64_arm64] arch: [x86, x64, arm64]
ossl: [openssl, openssl3] ossl: [ossl1.1.1, ossl3]
include:
- arch: amd64_arm64
triplet: arm64
- arch: x86
triplet: x86
- arch: amd64
triplet: x64
env: env:
# Indicates the location of the vcpkg as a Git submodule of the project repository. # Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/vcpkg VCPKG_ROOT: ${{ github.workspace }}/vcpkg
SOLUTION_FILE_PATH: .
BUILD_CONFIGURATION: Release
VCPKG_OVERLAY_PORTS: '${{ github.workspace }}/openvpn/contrib/vcpkg-ports'
buildDir: '${{ github.workspace }}/build/'
name: "msvc - ${{matrix.triplet}} - ${{ matrix.ossl }}" name: 'msvc - ${{matrix.arch}} - ${{ matrix.ossl }}'
runs-on: windows-latest runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: lukka/get-cmake@latest - uses: lukka/get-cmake@latest
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Clone openvpn repo - name: Restore artifacts, or setup vcpkg (do not install any package)
uses: actions/checkout@v2 uses: lukka/run-vcpkg@v10
with: with:
repository: openvpn/openvpn vcpkgGitCommitId: "a5d6d145164e82e67fbf91a4a30f98699d30de63"
path: openvpn appendedCacheKey: "${{ matrix.arch }} - ${{ matrix.ossl }}"
- name: Install dependencies - name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg.
uses: lukka/run-vcpkg@v7.4 uses: lukka/run-cmake@v10
with: with:
vcpkgGitCommitId: 'b18b17865cfb6bd24620a00f30691be6775abb96' configurePreset: '${{ matrix.arch }}-release-${{ matrix.ossl }}'
vcpkgArguments: ${{ matrix.ossl }} buildPreset: '${{ matrix.arch }}-release-${{ matrix.ossl }}'
vcpkgTriplet: '${{ matrix.triplet }}-windows'
- name: Build - uses: actions/upload-artifact@v3
uses: lukka/run-cmake@v3
with: with:
useVcpkgToolchainFile: true name: openvpn-gui_${{ matrix.arch }}_${{ matrix.ossl }}
buildWithCMake: true
cmakeBuildType: ${{env.BUILD_CONFIGURATION}}
buildDirectory: ${{ env.buildDir }}
- uses: actions/upload-artifact@v2
with:
name: openvpn-gui_${{ matrix.triplet }}_${{ matrix.ossl }}
path: | path: |
${{ env.buildDir }}/*.exe out/build/${{ matrix.arch }}-release-${{ matrix.ossl }}/*.dll
${{ env.buildDir }}/*.dll out/build/${{ matrix.arch }}-release-${{ matrix.ossl }}/*.exe
mingw: mingw:
strategy: strategy:

1
.gitignore vendored
View File

@ -34,3 +34,4 @@ missing
.vs .vs
x64 x64
Debug Debug
out

View File

@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
if(NOT VCPKG_MANIFEST_DIR)
set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/vcpkg_manifests/openssl_3)
endif()
project(openvpn-gui C) project(openvpn-gui C)
add_executable(${PROJECT_NAME} WIN32 add_executable(${PROJECT_NAME} WIN32
@ -66,3 +70,11 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
UNICODE UNICODE
WIN32_LEAN_AND_MEAN WIN32_LEAN_AND_MEAN
HAVE_CONFIG_H) HAVE_CONFIG_H)
if(MSVC)
# work around msvc generator Debug/Release directory ugliness, doesn't apply for Ninja
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:>
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:>
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<0:>)
endif(MSVC)

173
CMakePresets.json Normal file
View File

@ -0,0 +1,173 @@
{
"version": 2,
"configurePresets": [
{
"name": "base",
"hidden": true,
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
}
},
"vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ "Windows" ] } }
},
{
"name": "ossl3",
"hidden": true,
"cacheVariables": {
"VCPKG_MANIFEST_DIR": "${sourceDir}/vcpkg_manifests/openssl_3"
}
},
{
"name": "ossl1.1.1",
"hidden": true,
"cacheVariables": {
"VCPKG_MANIFEST_DIR": "${sourceDir}/vcpkg_manifests/openssl_1.1.1"
}
},
{
"name": "x64",
"generator": "Ninja",
"hidden": true,
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "arm64",
"generator": "Ninja",
"hidden": true,
"architecture": {
"value": "arm64",
"strategy": "external"
}
},
{
"name": "x86",
"generator": "Visual Studio 16 2019",
"hidden": true,
"architecture": {
"value": "Win32"
}
},
{
"name": "debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-debug-ossl3",
"inherits": [ "base", "ossl3", "x64", "debug" ]
},
{
"name": "x64-debug-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "x64", "debug" ]
},
{
"name": "arm64-debug-ossl3",
"inherits": [ "base", "ossl3", "arm64", "debug" ]
},
{
"name": "arm64-debug-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "arm64", "debug" ]
},
{
"name": "x86-debug-ossl3",
"inherits": [ "base", "ossl3", "x86", "debug" ]
},
{
"name": "x86-debug-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "x86", "debug" ]
},
{
"name": "x64-release-ossl3",
"inherits": [ "base", "ossl3", "x64", "release" ]
},
{
"name": "x64-release-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "x64", "release" ]
},
{
"name": "arm64-release-ossl3",
"inherits": [ "base", "ossl3", "arm64", "release" ]
},
{
"name": "arm64-release-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "arm64", "release" ]
},
{
"name": "x86-release-ossl3",
"inherits": [ "base", "ossl3", "x86", "release" ]
},
{
"name": "x86-release-ossl1.1.1",
"inherits": [ "base", "ossl1.1.1", "x86", "release" ]
}
],
"buildPresets": [
{
"name": "x64-release-ossl3",
"configurePreset": "x64-release-ossl3"
},
{
"name": "x64-release-ossl1.1.1",
"configurePreset": "x64-release-ossl1.1.1"
},
{
"name": "x86-release-ossl3",
"configurePreset": "x86-release-ossl3",
"configuration": "Release"
},
{
"name": "x86-release-ossl1.1.1",
"configurePreset": "x86-release-ossl1.1.1",
"configuration": "Release"
},
{
"name": "arm64-release-ossl3",
"configurePreset": "arm64-release-ossl3"
},
{
"name": "arm64-release-ossl1.1.1",
"configurePreset": "arm64-release-ossl1.1.1"
},
{
"name": "x64-debug-ossl3",
"configurePreset": "x64-debug-ossl3"
},
{
"name": "x64-debug-ossl1.1.1",
"configurePreset": "x64-debug-ossl1.1.1"
},
{
"name": "x86-debug-ossl3",
"configurePreset": "x86-debug-ossl3",
"configuration": "Debug"
},
{
"name": "x86-debug-ossl1.1.1",
"configurePreset": "x86-debug-ossl1.1.1",
"configuration": "Debug"
},
{
"name": "arm64-debug-ossl3",
"configurePreset": "arm64-debug-ossl3"
},
{
"name": "arm64-debug-ossl1.1.1",
"configurePreset": "arm64-debug-ossl1.1.1"
}
]
}

View File

@ -0,0 +1,14 @@
{
"name": "openvpn-gui",
"version-string": "0.0.1",
"dependencies": [
"openssl"
],
"builtin-baseline": "4b766c1cd17205e1b768c4fadfd5f867c1d0510e",
"overrides": [
{
"name": "openssl",
"version-string": "1.1.1n"
}
]
}

View File

@ -0,0 +1,7 @@
{
"name": "openvpn-gui",
"version-string": "0.0.1",
"dependencies": [
"openssl"
]
}