Skip to content

cmake: add support for compiling bitpit with MSVC #74

cmake: add support for compiling bitpit with MSVC

cmake: add support for compiling bitpit with MSVC #74

name: Continuous integration
on:
workflow_dispatch:
inputs:
pull_request:
branches: [ "master" ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
# setup-lnux:
# runs-on: ubuntu
# name: Setup - Linux
# steps:
# - name: Checkout build environment information
# uses: actions/checkout@v3
# with:
# path: bitpit
# sparse-checkout: |
# environments
# - name: Build environment
# shell: bash
# run: |
# DOCKER_BUILDKIT=1 docker buildx build \
# --builder=container \
# --cache-from type=local,src=/home/bob/products/bitpit/ubuntu-cache \
# --cache-to type=local,dest=/home/bob/products/bitpit/ubuntu-cache \
# --rm \
# --target bitpit-environment \
# -f bitpit/environments/ubuntu/Dockerfile .
# - name: Cleanup build environment information
# run: |
# rm -rf bitpit
# tests-linux:
# runs-on: ubuntu
# needs: setup-linux
# name: Linux - (${{ matrix.compiler }}) MPI ${{ matrix.mpi }} - Debug ${{ matrix.debug }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - compiler: gcc
# mpi: ON
# debug: ON
# - compiler: gcc
# mpi: ON
# debug: OFF
# - compiler: gcc
# mpi: OFF
# debug: ON
# - compiler: gcc
# mpi: OFF
# debug: OFF
# - compiler: clang
# mpi: ON
# debug: OFF
# steps:
# - name: Checkout bitpit
# uses: actions/checkout@v3
# - name: Build bitpit
# shell: bash
# run: |
# DOCKER_BUILDKIT=1 docker buildx build \
# --builder=container \
# --cache-from type=local,src=/home/bob/products/bitpit/ubuntu-cache \
# --rm \
# --build-arg COMPILER=${{ matrix.compiler }} \
# --build-arg MPI=${{ matrix.mpi }} \
# --build-arg DEBUG=${{ matrix.debug }} \
# --target bitpit-build \
# -f environments/ubuntu/Dockerfile .
# - name: Run bitpit tests
# shell: bash
# run: |
# DOCKER_BUILDKIT=1 docker buildx build \
# --builder=container \
# --cache-from type=local,src=/home/bob/products/bitpit/ubuntu-cache \
# --rm \
# --build-arg COMPILER=${{ matrix.compiler }} \
# --build-arg MPI=${{ matrix.mpi }} \
# --build-arg DEBUG=${{ matrix.debug }} \
# --target bitpit-test \
# -f environments/ubuntu/Dockerfile .
tests-windows:
runs-on: Windows
name: Windows - (MSVC) MPI ${{ matrix.mpi }} - Debug ${{ matrix.debug }}
strategy:
fail-fast: false
matrix:
include:
- mpi: ON
debug: ON
- mpi: ON
debug: OFF
- mpi: OFF
debug: ON
- mpi: OFF
debug: OFF
steps:
- uses: actions/checkout@v3
- name: Build bitpit
shell: cmd
run: |
echo OFF
echo Prepare environment
REM Calling setvars.bat works properly only if called with call statement.
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
IF %SETVARS_COMPLETED% == 1 (echo MKL status.......... Loaded) else (echo MKL status.......... Error)
IF "${{ matrix.mpi }}" == "ON" (echo Parallel paradigm... MPI) else (echo Parallel paradigm... Serial)
IF "${{ matrix.debug }}" == "ON" (set "buildtype=Debug") ELSE (set "buildtype=Release")
echo Build type.......... %buildtype%
set "petscdir=C:\petsc\3_19_5"
IF "${{ matrix.mpi }}" == "OFF" (set "petscdir=%petscdir%SERIAL")
echo PETSc directory..... %petscdir%
IF exist build (rmdir /q /s build)
mkdir build
cd build
echo Configure bitpit
set "cmake-command="C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 17 2022""
set "cmake-command=%cmake-command% -DBoost_USE_STATIC_LIBS=OFF"
set "cmake-command=%cmake-command% -DBoost_DIR:PATH=C:\optimad-dependencies\boost\lib\cmake\Boost-1.82.0"
set "cmake-command=%cmake-command% -DBoost_INCLUDE_DIR:PATH=C:\optimad-dependencies\boost\include"
set "cmake-command=%cmake-command% -DBITPIT_BUILD_EXAMPLES=ON"
set "cmake-command=%cmake-command% -DBITPIT_ENABLE_INTEGRATION_TESTS=ON"
set "cmake-command=%cmake-command% -DBITPIT_ENABLE_MPI=${{ matrix.mpi }}"
set "cmake-command=%cmake-command% -DBITPIT_ENABLE_UNIT_TESTS=ON"
set "cmake-command=%cmake-command% -DBUILD_SHARED_LIBS=ON"
set "cmake-command=%cmake-command% -DBUILD_TESTING=ON"
set "cmake-command=%cmake-command% -DCMAKE_BUILD_TYPE=%buildtype%"
set "cmake-command=%cmake-command% -DCMAKE_CONFIGURATION_TYPES=%buildtype%"
set "cmake-command=%cmake-command% -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
IF "${{ matrix.mpi }}" == "ON" (set "cmake-command=%cmake-command% -DMETIS_DIR=C:\optimad-dependencies\metis-5.1.0-win\dynamic\")
set "cmake-command=%cmake-command% -DPETSC_DIR=%petscdir%"
set "cmake-command=%cmake-command% .."
%cmake-command%
echo Build bitpit
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" bitpit.sln /t:ALL_BUILD /p:Configuration=%buildtype% /p:Platform=x64
- name: Run bitpit tests
shell: powershell
run: |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# Copy dependencies and add them to PATH
# TODO: put the dependencies find and copy inside cmake files (everything apart mkl and curl can be found)
$WORKDIR ="$PWD\.."
if ("${{ matrix.mpi }}" -eq "ON") {
$BITPIT_LIBS = "C:\bitpit\bitpit-libraries"
} else {
$BITPIT_LIBS = "C:\bitpit\bitpit-libraries-serial"
}
Write-Host "Collecting bitpit deps in $BITPIT_LIBS"
$BITPIT_DEPS = "C:\optimad-dependencies\"
if (Test-Path -Path $BITPIT_LIBS) {
#removing forcefully the old libraries folder
Remove-Item $BITPIT_LIBS -Recurse -Force
}
#create an empty library folder
New-Item -Path $BITPIT_LIBS -ItemType Directory
cp "$BITPIT_DEPS\boost\lib\*.dll" $BITPIT_LIBS
cp -r "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\redist\intel64\*" $BITPIT_LIBS
cp "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler\*.dll" $BITPIT_LIBS
if ("${{ matrix.mpi }}" -eq "1") {
Write-Host "copying mpi, metis and MPI petsc"
cp "C:\Windows\System32\msmpi.dll" $BITPIT_LIBS
cp "$BITPIT_DEPS\metis-5.1.0-win\dynamic\lib\*.dll" $BITPIT_LIBS
cp "C:\petsc\3_19_5\lib\*.dll" $BITPIT_LIBS
} else {
Write-Host "copying serial petsc"
cp "C:\petsc\3_19_5SERIAL\lib\*.dll" $BITPIT_LIBS
}
cp "$WORKDIR\bitpit-install\bin\*.dll" $BITPIT_LIBS
# Set environment PATH
$env:Path += ";$BITPIT_LIBS"
# Run tests
cd build
$ctest_command = "ctest.exe -C Release"
Invoke-Expression $ctest_command