-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: backport CMake buildsystem from master to release/2.6
This is based on the initial CMake patch by Arne Schwabe, but extends that to provide a complete replacement for existing MinGW build (autotools based) and MSVC build (openvpn.sln). The following features are added while switching these builds to CMake: - vcpkg support for MinGW build, allowing for trivial cross-compilation on Linux - Add unittests to MSVC build - Rework MSVC config header generation, removing need for separate headers between autotools and MSVC The following advantages are reasons for switching to CMake over the existing MSVC build: - Easier to maintain CMake files without IDE than the sln and vcxproj files - Able to maintain MSVC and MinGW build side-by-side The plan is to completely remove the existing MSVC build system but leave the existing autotools builds in place as-is, including MinGW support. CMake is not the intended build system for Unix-like platforms and there are no current plans to switch to it. This commits squashes a lot of commits from master together, since most of them are just fixes or enhancements for the original CMake commit. The decisions was not to bloat the release/2.6 commit history with these detours. It contains the following commits: - add basic CMake based build (commit 0134184 by Arne Schwabe) - CMake: Add complete MinGW and MSVC build (commit e8881ec) - CMake: Add /Brepro to MSVC link options (commit 5e94e8d) - Do not blindly assume python3 is also the interpreter that runs rst2html (commit 5dbec1c by Arne Schwabe) - Only add -Wno-stringop-truncation on supported compilers (commit eb3cd5e by Arne Schwabe) - CMake: Throw a clear error when config.h in top-level source directory (commit 0652ae8) - openvpnmsica: link C runtime statically (commit 3be4986 by Lev Stipakov) - CMake: Support doc builds on Windows machines that do not have .py file association (commit 22213a8) - README.cmake.md: Add new documentation for CMake buildsystem (commit 53055fd) - Check if the -wrap argument is actually supported by the platform's ld (commit 4ef76f0 by Arne Schwabe) - GHA: update to run-vcpkg@v11 (commit 66e33ee) - GHA: refactor mingw UTs and add missing tls_crypt (commit 26c663f) - CMake: various small non-functional improvements (commit 95cc5fa) - CMake: fix broken daemonization and syslog functionality (commit 8ae6c48) - CMake: fix HAVE_DAEMON detection on Linux (commit e363b39) Change-Id: I6de18261d5dc7f8561612184059656c73f33a5f2 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Lev Stipakov <[email protected]> Co-authored-by: Arne Schwabe <[email protected]> Co-authored-by: Lev Stipakov <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg27107.html Signed-off-by: Gert Doering <[email protected]>
- Loading branch information
Showing
24 changed files
with
2,101 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,230 +39,64 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
osslver: [1.1.1q, 3.0.5] | ||
target: [mingw64, mingw] | ||
include: | ||
- target: mingw64 | ||
chost: x86_64-w64-mingw32 | ||
- target: mingw | ||
chost: i686-w64-mingw32 | ||
arch: [x86, x64] | ||
|
||
name: "gcc-mingw - ${{matrix.target}} - OSSL ${{ matrix.osslver }}" | ||
name: "gcc-mingw - ${{ matrix.arch }} - OSSL" | ||
runs-on: ubuntu-22.04 | ||
env: | ||
MAKEFLAGS: -j3 | ||
LZO_VERSION: "2.10" | ||
PKCS11_HELPER_VERSION: "1.29.0" | ||
OPENSSL_VERSION: "${{ matrix.osslver }}" | ||
TAP_WINDOWS_VERSION: "9.23.3" | ||
CMOCKA_VERSION: "1.1.5" | ||
VCPKG_ROOT: ${{ github.workspace }}/vcpkg | ||
steps: | ||
- name: Install dependencies | ||
run: sudo apt update && sudo apt install -y mingw-w64 libtool automake autoconf man2html unzip cmake ninja-build build-essential wget | ||
run: sudo apt update && sudo apt install -y mingw-w64 unzip cmake ninja-build build-essential wget python3-docutils man2html-base | ||
- name: Checkout OpenVPN | ||
uses: actions/checkout@v3 | ||
with: | ||
path: openvpn | ||
|
||
- name: autoconf | ||
run: autoreconf -fvi | ||
working-directory: openvpn | ||
|
||
- name: Cache dependencies | ||
id: cache | ||
uses: actions/cache@v3 | ||
- name: Restore from cache and install vcpkg | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
path: '~/mingw/' | ||
key: ${{ matrix.target }}-mingw-${{ matrix.osslver }}-${{ env.LZO_VERSION }}-${{ env.PKCS11_HELPER_VERSION }}-${{ env.TAP_WINDOWS_VERSION }}--${{ env.CMOCKA_VERSION }} | ||
|
||
# Repeating if: steps.cache.outputs.cache-hit != 'true' | ||
# on every step for building dependencies is ugly but | ||
# I haven't found a better solution so far. | ||
|
||
- name: Download mingw dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
wget -c -P download-cache/ "https://build.openvpn.net/downloads/releases/tap-windows-${TAP_WINDOWS_VERSION}.zip" | ||
wget -c -P download-cache/ "https://www.oberhumer.com/opensource/lzo/download/lzo-${LZO_VERSION}.tar.gz" | ||
wget -c -P download-cache/ "https://github.com/OpenSC/pkcs11-helper/releases/download/pkcs11-helper-${PKCS11_HELPER_VERSION}/pkcs11-helper-${PKCS11_HELPER_VERSION}.tar.bz2" | ||
wget -c -P download-cache/ "https://github.com/coreboot/cmocka/archive/refs/tags/cmocka-${CMOCKA_VERSION}.tar.gz" | ||
tar jxf "download-cache/pkcs11-helper-${PKCS11_HELPER_VERSION}.tar.bz2" | ||
wget -c -P download-cache/ "https://www.openssl.org/source/old/1.1.1/openssl-${OPENSSL_VERSION}.tar.gz" || wget -c -P download-cache/ "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" | ||
tar zxf "download-cache/openssl-${OPENSSL_VERSION}.tar.gz" | ||
tar zxf "download-cache/lzo-${LZO_VERSION}.tar.gz" | ||
tar zxf "download-cache/cmocka-${CMOCKA_VERSION}.tar.gz" | ||
unzip download-cache/tap-windows-${TAP_WINDOWS_VERSION}.zip | ||
- name: create cmocka build directory | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: mkdir cmocka-build | ||
|
||
- name: configure cmocka | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: "./cmocka-build" | ||
run: cmake -GNinja -DCMAKE_C_COMPILER=${{ matrix.chost }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.chost }}-g++ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SHARED_LINKER_FLAGS=-static-libgcc -DCMAKE_PREFIX_PATH=${HOME}/mingw/opt/lib/pkgconfig/ -DCMAKE_INCLUDE_PATH=${HOME}/mingw/opt/lib/include -DCMAKE_LIBRARY_PATH=${HOME}/mingw/opt/lib -DCMAKE_INSTALL_PREFIX=${HOME}/mingw/opt/ ../cmocka-cmocka-${{ env.CMOCKA_VERSION }} | ||
|
||
- name: build cmocka | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: "./cmocka-build" | ||
run: ninja | ||
|
||
- name: install cmocka | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: "./cmocka-build" | ||
run: ninja install | ||
|
||
- name: Configure OpenSSL | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: ./Configure --cross-compile-prefix=${{ matrix.chost }}- shared ${{ matrix.target }} no-capieng --prefix="${HOME}/mingw/opt" --openssldir="${HOME}/mingw/opt" -static-libgcc | ||
working-directory: "./openssl-${{ env.OPENSSL_VERSION }}" | ||
|
||
- name: Build OpenSSL | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: make | ||
working-directory: "./openssl-${{ env.OPENSSL_VERSION }}" | ||
|
||
# OpenSSL 3.0.5 installs itself into mingw/opt/lib64 instead of | ||
# mingw/opt/lib, so we include both dirs in the following steps | ||
# (pkcs11-helper and OpenVPN) so the libraries will be found | ||
- name: Install OpenSSL | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: make install | ||
working-directory: "./openssl-${{ env.OPENSSL_VERSION }}" | ||
|
||
- name: autoreconf pkcs11-helper | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: autoreconf -iv | ||
working-directory: "./pkcs11-helper-${{ env.PKCS11_HELPER_VERSION }}" | ||
|
||
- name: configure pkcs11-helper | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: OPENSSL_LIBS="-L${HOME}/mingw/opt/lib -L${HOME}/mingw/opt/lib64 -lssl -lcrypto" OPENSSL_CFLAGS=-I$HOME/mingw/opt/include PKG_CONFIG_PATH=${HOME}/mingw/opt/lib/pkgconfig ./configure --host=${{ matrix.chost }} --program-prefix='' --libdir=${HOME}/mingw/opt/lib --prefix=${HOME}/mingw/opt --build=x86_64-pc-linux-gnu --disable-crypto-engine-gnutls --disable-crypto-engine-nss --disable-crypto-engine-polarssl --disable-crypto-engine-mbedtls | ||
working-directory: "./pkcs11-helper-${{ env.PKCS11_HELPER_VERSION }}" | ||
|
||
- name: build pkcs11-helper | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: make all | ||
working-directory: "./pkcs11-helper-${{ env.PKCS11_HELPER_VERSION }}" | ||
|
||
- name: install pkcs11-helper | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: make install | ||
working-directory: "./pkcs11-helper-${{ env.PKCS11_HELPER_VERSION }}" | ||
|
||
- name: Configure lzo | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: ./configure --host=${{ matrix.chost }} --program-prefix='' --libdir=${HOME}/mingw/opt/lib --prefix=${HOME}/mingw/opt --build=x86_64-pc-linux-gnu | ||
working-directory: "./lzo-${{ env.LZO_VERSION }}" | ||
|
||
- name: build lzo | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: "./lzo-${{ env.LZO_VERSION }}" | ||
run: make | ||
|
||
- name: install lzo | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
working-directory: "./lzo-${{ env.LZO_VERSION }}" | ||
run: make install | ||
|
||
- name: copy tap-windows.h header | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: cp ./tap-windows-${TAP_WINDOWS_VERSION}/include/tap-windows.h ${HOME}/mingw/opt/include/ | ||
|
||
- name: configure OpenVPN | ||
run: PKG_CONFIG_PATH=${HOME}/mingw/opt/lib/pkgconfig LDFLAGS=-L$HOME/mingw/opt/lib CFLAGS=-I$HOME/mingw/opt/include OPENSSL_LIBS="-L${HOME}/opt/lib -L$HOME/mingw/opt/lib64 -lssl -lcrypto" OPENSSL_CFLAGS=-I$HOME/mingw/opt/include PREFIX=$HOME/mingw/opt LZO_CFLAGS=-I$HOME/mingw/opt/include LZO_LIBS="-L${HOME}/mingw/opt/lib -llzo2" ./configure --host=${{ matrix.chost }} --disable-lz4 | ||
working-directory: openvpn | ||
|
||
- name: build OpenVPN | ||
run: make -j3 | ||
working-directory: openvpn | ||
- name: build OpenVPN unittests | ||
run: make -j3 check | ||
working-directory: openvpn | ||
vcpkgGitCommitId: '1ba9a2591f15af5900f2ce2b3e2bf31771e3ac48' | ||
vcpkgJsonGlob: '**/mingw/vcpkg.json' | ||
|
||
# We use multiple upload-artifact here, so it becomes a flat folder | ||
# structure since we need the dlls on the same level as the binaries | ||
- name: Archive cmocka/openssl/lzo dlls | ||
uses: actions/upload-artifact@v3 | ||
- name: Run CMake with vcpkg.json manifest | ||
uses: lukka/run-cmake@v10 | ||
with: | ||
retention-days: 1 | ||
name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-dlls | ||
path: '~/mingw/opt/bin/*.dll' | ||
configurePreset: mingw-${{ matrix.arch }} | ||
buildPreset: mingw-${{ matrix.arch }} | ||
buildPresetAdditionalArgs: "['--config Debug']" | ||
|
||
# libtool puts some wrapper binaries in openvpn/tests/unit_tests/openvpn/ | ||
# and the real binaries in openvpn/tests/unit_tests/openvpn/.libs/ | ||
- name: Archive unittest artifacts | ||
uses: actions/upload-artifact@v3 | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
retention-days: 1 | ||
name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests | ||
path: openvpn/tests/unit_tests/openvpn/.libs/*.exe | ||
name: openvpn-mingw-${{ matrix.arch }} | ||
path: | | ||
${{ github.workspace }}/out/build/mingw/${{ matrix.arch }}/Debug/*.exe | ||
${{ github.workspace }}/out/build/mingw/${{ matrix.arch }}/Debug/*.dll | ||
!${{ github.workspace }}/out/build/mingw/${{ matrix.arch }}/Debug/test_*.exe | ||
# Currently not used by the unit test but might in the future and also | ||
# helpful if manually downloading and running openvpn.exe from a mingw | ||
# build | ||
- name: Archive openvpn binary | ||
uses: actions/upload-artifact@v3 | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
retention-days: 1 | ||
name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests | ||
path: openvpn/src/openvpn/.libs/*.exe | ||
name: openvpn-mingw-${{ matrix.arch }}-tests | ||
path: | | ||
${{ github.workspace }}/out/build/mingw/${{ matrix.arch }}/Debug/test_*.exe | ||
${{ github.workspace }}/out/build/mingw/${{ matrix.arch }}/Debug/*.dll | ||
mingw-unittest: | ||
needs: [ mingw ] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
osslver: [ 1.1.1q, 3.0.5 ] | ||
target: [ mingw64, mingw ] | ||
arch: [x86, x64] | ||
test: [argv, auth_token, buffer, cryptoapi, crypto, misc, ncp, packet_id, pkt, provider, tls_crypt] | ||
|
||
runs-on: windows-latest | ||
name: "mingw unittests - ${{matrix.target}} - OSSL ${{ matrix.osslver }}" | ||
name: "mingw unittest ${{ matrix.test }} - ${{ matrix.arch }} - OSSL" | ||
steps: | ||
- name: Retrieve mingw unittest dlls | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-dlls | ||
path: unittests | ||
|
||
- name: Retrieve mingw unittest | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: mingw-unittest-${{matrix.target}}-ossl${{ matrix.osslver }}-tests | ||
name: openvpn-mingw-${{ matrix.arch }}-tests | ||
path: unittests | ||
|
||
- name: List unittests directory | ||
run: "dir unittests" | ||
|
||
- name: Run argvunit test | ||
run: ./unittests/argv_testdriver.exe | ||
|
||
- name: Run auth_tokenunit test | ||
run: ./unittests/auth_token_testdriver.exe | ||
|
||
- name: Run bufferunit test | ||
run: ./unittests/buffer_testdriver.exe | ||
|
||
- name: Run cryptoapi unit test | ||
run: ./unittests/cryptoapi_testdriver.exe | ||
|
||
- name: Run cryptounit test | ||
run: ./unittests/crypto_testdriver.exe | ||
|
||
- name: Run miscunit test | ||
run: ./unittests/misc_testdriver.exe | ||
|
||
- name: Run ncpunit test | ||
run: ./unittests/ncp_testdriver.exe | ||
|
||
- name: Run packet idunit test | ||
run: ./unittests/packet_id_testdriver.exe | ||
|
||
- name: Run pktunit test | ||
run: ./unittests/pkt_testdriver.exe | ||
|
||
- name: Run providerunit test | ||
run: ./unittests/provider_testdriver.exe | ||
- name: Run ${{ matrix.test }} unit test | ||
run: ./unittests/test_${{ matrix.test }}.exe | ||
|
||
ubuntu: | ||
strategy: | ||
|
@@ -407,60 +241,50 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
plat: [ARM64, Win32, x64] | ||
include: | ||
- plat: ARM64 | ||
triplet: arm64 | ||
- plat: Win32 | ||
triplet: x86 | ||
- plat: x64 | ||
triplet: x64 | ||
arch: [amd64, x86, arm64] | ||
|
||
name: "msbuild - ${{matrix.triplet}} - openssl" | ||
name: "msbuild - ${{ matrix.arch }} - openssl" | ||
env: | ||
BUILD_CONFIGURATION: Release | ||
VCPKG_OVERLAY_PORTS: ${{ github.workspace }}/contrib/vcpkg-ports | ||
VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}/contrib/vcpkg-triplets | ||
|
||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Add MSBuild to PATH | ||
uses: microsoft/[email protected] | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- uses: lukka/get-cmake@latest | ||
|
||
- name: Install rst2html | ||
run: python -m pip install --upgrade pip rst2html | ||
run: python -m pip install --upgrade pip docutils | ||
|
||
- name: Restore artifacts, or setup vcpkg (do not install any package) | ||
uses: lukka/run-vcpkg@v10 | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
vcpkgGitCommitId: 'd10d511f25620ca0f315cd83dcef6485efc63010' | ||
vcpkgJsonGlob: '**/openvpn/vcpkg.json' | ||
appendedCacheKey: '${{matrix.triplet}}' | ||
vcpkgGitCommitId: '1ba9a2591f15af5900f2ce2b3e2bf31771e3ac48' | ||
vcpkgJsonGlob: '**/windows/vcpkg.json' | ||
|
||
- name: Run MSBuild consuming vcpkg.json | ||
working-directory: ${{env.GITHUB_WORKSPACE}} | ||
run: | | ||
# workaround for GHA runner bug where vcpkg installation is detected at c:\vcpkg | ||
# see https://github.com/lukka/run-vcpkg/issues/170 | ||
${{ github.workspace }}/vcpkg/vcpkg.exe integrate install | ||
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform="${{ matrix.plat }}" . | ||
- name: Run CMake with vcpkg.json manifest (NO TESTS) | ||
uses: lukka/run-cmake@v10 | ||
if: ${{ matrix.arch == 'arm64' }} | ||
with: | ||
configurePreset: win-${{ matrix.arch }}-release | ||
buildPreset: win-${{ matrix.arch }}-release | ||
|
||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
- name: Run CMake with vcpkg.json manifest | ||
uses: lukka/run-cmake@v10 | ||
if: ${{ matrix.arch != 'arm64' }} | ||
with: | ||
configurePreset: win-${{ matrix.arch }}-release | ||
buildPreset: win-${{ matrix.arch }}-release | ||
testPreset: win-${{ matrix.arch }}-release | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts-${{ matrix.plat }} | ||
name: openvpn-msvc-${{ matrix.arch }} | ||
path: | | ||
${{ matrix.plat }}-Output/${{env.BUILD_CONFIGURATION}}/*.exe | ||
${{ matrix.plat }}-Output/${{env.BUILD_CONFIGURATION}}/*.dll | ||
${{ matrix.plat }}-Output/${{env.BUILD_CONFIGURATION}}/*.pdb | ||
doc/openvpn.8.html | ||
${{ github.workspace }}/out/**/*.exe | ||
${{ github.workspace }}/out/**/*.dll | ||
!${{ github.workspace }}/out/**/test_*.exe | ||
!${{ github.workspace }}/out/**/CMakeFiles/** | ||
!${{ github.workspace }}/out/**/vcpkg_installed/** | ||
libressl: | ||
strategy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
Release | ||
Debug | ||
Win32-Output | ||
out | ||
.vs | ||
.deps | ||
.libs | ||
|
Oops, something went wrong.