From 9d4faab2d330df8b032995ed58f757c25b1c68c7 Mon Sep 17 00:00:00 2001 From: qnfm <104289862+qnfm@users.noreply.github.com> Date: Sun, 24 Sep 2023 13:29:16 +0100 Subject: [PATCH] CI & cmake changes for Windows (#263) * Fix OQS_ADDL_SOCKET_LIBS setting for cmake * Test Windows 2019 with VS 16 2019 * Add path for VS * Avoid openssl cache conflict * Add build type into matrix --------- Co-authored-by: a --- .github/workflows/windows.yml | 104 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- test/CMakeLists.txt | 4 ++ 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e18da010..a5b187a6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -199,3 +199,107 @@ jobs: name: oqs-provider-msvc path: D:/a/oqs-provider/oqs-provider/_build/lib/oqsprovider.dll + msvc_native: +# Run a job for each of the specified target architectures: + strategy: + matrix: + os: + - windows-2019 + - windows-2022 + platform: + - arch: win64 + oqsconfig: -DOQS_ALGS_ENABLED=STD + osslconfig: no-shared no-fips VC-WIN64A + toolchain: + - .CMake/toolchain_windows_amd64.cmake + msarch: + - x64 + type: + - Debug + - Release + runs-on: ${{matrix.os}} + steps: + - name: Restore native OpenSSL32 cache + id: cache-openssl32n + uses: actions/cache@v3 + with: + path: c:\openssl32n + key: ${{ runner.os }}-msvcopenssl32n + - uses: actions/checkout@v3 + - name: Checkout OpenSSL master + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + set-safe-directory: true + repository: openssl/openssl + path: openssl + - uses: actions/checkout@v3 + with: + set-safe-directory: true + repository: open-quantum-safe/liboqs + path: liboqs + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.platform.arch }} + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1 + with: + msbuild-architecture: ${{matrix.msarch}} + vs-version: '[16.10,]' + - name: Setup nasm for OpenSSL build + uses: ilammy/setup-nasm@v1 + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + with: + platform: ${{ matrix.platform.arch }} + - name: Setup perl for OpenSSL build + uses: shogo82148/actions-setup-perl@v1 + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + - name: build liboqs + run: | + cmake --version + cmake -B build --toolchain ${{ matrix.toolchain }} . + cmake --build build + cmake --build build --target INSTALL + working-directory: liboqs + - name: prepare the OpenSSL build directory + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + run: mkdir _build + working-directory: openssl + - name: OpenSSL config + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + working-directory: openssl\_build + run: | + perl ..\Configure --banner=Configured --prefix=c:\openssl32n no-makedepend ${{ matrix.platform.osslconfig }} + perl configdata.pm --dump + - name: OpenSSL build + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + working-directory: openssl\_build + run: nmake /S + - name: OpenSSL install +# Run on 64 bit only as 32 bit is slow enough already + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + run: | + mkdir c:\openssl32n + nmake install_sw + working-directory: openssl\_build + - name: Save OpenSSL + id: cache-openssl-save + if: steps.cache-openssl32n.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: | + c:\openssl32n + key: ${{ runner.os }}-msvcopenssl32n + - name: build oqs-provider + run: | + cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_FLAGS="/wd5105" -DOPENSSL_ROOT_DIR="c:\openssl32n" -Dliboqs_DIR="c:\liboqs\lib\cmake\liboqs" -S . -B _build + cmake --build _build --config=${{ matrix.type }} + - name: Run tests + run: | + ctest --test-dir _build -C ${{ matrix.type }} + - name: Retain oqsprovider.dll + uses: actions/upload-artifact@v3 + with: + name: oqs-provider-msvc + path: D:/a/oqs-provider/oqs-provider/_build/lib/oqsprovider.dll + diff --git a/CMakeLists.txt b/CMakeLists.txt index cbabf462..002a4e9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if(MSVC) "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT") add_definitions(-DOQS_PROVIDER_NOATOMIC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) - set(OQS_ADDL_SOCKET_LIBS "ws2_32.lib gdi32.lib crypt32.lib") + set(OQS_ADDL_SOCKET_LIBS ws2_32.lib gdi32.lib crypt32.lib) else() add_compile_options(-Wunused-function) set(OQS_ADDL_SOCKET_LIBS "") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b39796ec..1c5fd96a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,9 @@ include(GNUInstallDirs) +if (CMAKE_GENERATOR MATCHES "Visual Studio") +set(OQS_PROV_BINARY_DIR ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) +else() set(OQS_PROV_BINARY_DIR ${CMAKE_BINARY_DIR}/lib) +endif() add_test( NAME oqs_signatures