Skip to content

cmake: add support for compiling bitpit with MSVC #92

cmake: add support for compiling bitpit with MSVC

cmake: add support for compiling bitpit with MSVC #92

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: powershell
# run: |
# cmd.exe "/K" 'call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'
#
# Write-Host ""
# Write-Host "Prepare environment"
#
# Write-Host -NoNewline " Parallel paradigm... "
# if ("${{ matrix.mpi }}" -eq "ON") {
# Write-Host "MPI"
# } else {
# Write-Host "Serial"
# }
#
# if ("${{ matrix.debug }}" -eq "ON") {
# $BUILD_TYPE = "Debug"
# } else {
# $BUILD_TYPE = "Release"
# }
# Write-Host " Build type.......... $BUILD_TYPE"
#
# $PETSC_DIR = "C:\petsc\3_19_5"
# if ("${{ matrix.mpi }}" -eq "ON") {
# $PETSC_DIR = "$PETSC_DIR""SERIAL"
# }
# Write-Host " PETSc directory..... $PETSC_DIR"
#
# if (Test-Path -Path "build") {
# rm "build"
# }
# mkdir build
# cd build
#
# Write-Host "Configure bitpit"
# $CMAKE_VARIABLES = ""
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBITPIT_BUILD_EXAMPLES=ON"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBITPIT_ENABLE_INTEGRATION_TESTS=ON"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBITPIT_ENABLE_MPI=${{ matrix.mpi }}"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBITPIT_ENABLE_UNIT_TESTS=ON"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBoost_USE_STATIC_LIBS=OFF"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBoost_DIR:PATH=C:\optimad-dependencies\boost\lib\cmake\Boost-1.82.0"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBoost_INCLUDE_DIR:PATH=C:\optimad-dependencies\boost\include"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBUILD_SHARED_LIBS=ON"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DBUILD_TESTING=ON"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DCMAKE_BUILD_TYPE=$BUILD_TYPE"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DCMAKE_CONFIGURATION_TYPES=$BUILD_TYPE"
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
# if ("${{ matrix.mpi }}" -eq "ON") {
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DMETIS_DIR=C:\optimad-dependencies\metis-5.1.0-win\dynamic\"
# }
# $CMAKE_VARIABLES = "$CMAKE_VARIABLES -DPETSC_DIR=$PETSC_DIR"
#
# & "C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 17 2022" "$CMAKE_VARIABLES" ..
#
# Write-Host "Build bitpit"
# & "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" bitpit.sln /t:ALL_BUILD /p:Configuration=$BUILD_TYPE /p:Platform=x64
- name: Build bitpit
shell: cmd
run: |
echo ON
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 "BUILD_TYPE=Debug") ELSE (set "BUILD_TYPE=Release")
echo Build type.......... %BUILD_TYPE%
set "PETSC_DIR=C:\petsc\3_19_5"
IF "${{ matrix.mpi }}" == "OFF" (set "PETSC_DIR=%PETSC_DIR%SERIAL")
echo PETSc directory..... %PETSC_DIR%
IF exist build (rmdir /q /s build)
mkdir build
cd build
echo Configure bitpit
set "CMAKE_VARIABLES="
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBoost_USE_STATIC_LIBS=OFF"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBoost_DIR:PATH=C:\optimad-dependencies\boost\lib\cmake\Boost-1.82.0"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBoost_INCLUDE_DIR:PATH=C:\optimad-dependencies\boost\include"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBITPIT_BUILD_EXAMPLES=ON"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBITPIT_ENABLE_INTEGRATION_TESTS=ON"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBITPIT_ENABLE_MPI=${{ matrix.mpi }}"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBITPIT_ENABLE_UNIT_TESTS=ON"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBUILD_SHARED_LIBS=ON"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DBUILD_TESTING=ON"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DCMAKE_BUILD_TYPE=%BUILD_TYPE%"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DCMAKE_CONFIGURATION_TYPES=%BUILD_TYPE%"
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON"
IF "${{ matrix.mpi }}" == "ON" (set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DMETIS_DIR=C:\optimad-dependencies\metis-5.1.0-win\dynamic\")
set "CMAKE_VARIABLES=%CMAKE_VARIABLES% -DPETSC_DIR=%PETSC_DIR%"
echo %CMAKE_VARIABLES%
"C:\Program Files\CMake\bin\cmake.exe" -G "Visual Studio 17 2022" %CMAKE_VARIABLES% ..
echo Build bitpit
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" bitpit.sln /t:ALL_BUILD /p:Configuration=%BUILD_TYPE% /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") {
# $LIBRARY_DIR = "C:\bitpit\bitpit-libraries"
# } else {
# $LIBRARY_DIR = "C:\bitpit\bitpit-libraries-serial"
# }
# Write-Host "Collecting bitpit deps in $LIBRARY_DIR"
# $BITPIT_DEPS = "C:\optimad-dependencies\"
#
# if (Test-Path -Path $LIBRARY_DIR) {
# #removing forcefully the old libraries folder
# Remove-Item $LIBRARY_DIR -Recurse -Force
# }
# #create an empty library folder
# New-Item -Path $LIBRARY_DIR -ItemType Directory
#
# cp "$BITPIT_DEPS\boost\lib\*.dll" $LIBRARY_DIR
# cp -r "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\redist\intel64\*" $LIBRARY_DIR
# cp "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler\*.dll" $LIBRARY_DIR
#
# if ("${{ matrix.mpi }}" -eq "1") {
# Write-Host "copying mpi, metis and MPI petsc"
# cp "C:\Windows\System32\msmpi.dll" $LIBRARY_DIR
# cp "$BITPIT_DEPS\metis-5.1.0-win\dynamic\lib\*.dll" $LIBRARY_DIR
# cp "C:\petsc\3_19_5\lib\*.dll" $LIBRARY_DIR
# } else {
# Write-Host "copying serial petsc"
# cp "C:\petsc\3_19_5SERIAL\lib\*.dll" $LIBRARY_DIR
# }
# cp "$WORKDIR\bitpit-install\bin\*.dll" $LIBRARY_DIR
#
# # Set environment PATH
# $env:Path += ";$LIBRARY_DIR"
#
# # Run tests
# cd build
# $ctest_command = "ctest.exe -C Release"
# Invoke-Expression $ctest_command
- name: Run bitpit tests
shell: cmd
run: |
IF "${{ matrix.debug }}" == "ON" (set "BUILD_TYPE=Debug") ELSE (set "BUILD_TYPE=Release")
echo Build type.......... %BUILD_TYPE%
# Set PATh variable
IF "${{ matrix.mpi }}" == "ON" (set PATH=%PATH%;"C:\Windows\System32\")
IF "${{ matrix.mpi }}" == "ON" (set PATH=%PATH%;"C:\optimad-dependencies\metis-5.1.0-win\dynamic\lib\")
set PATH=%PATH%;"C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\redist\intel64_win\compiler\"
set PATH=%PATH%;"C:\Program Files (x86)\Intel\oneAPI\mkl\latest\redist\intel64\"
set PATH=%PATH%;"C:\optimad-dependencies\boost\lib"
set "PETSC_DIR=C:\petsc\3_19_5"
IF "${{ matrix.mpi }}" == "OFF" (set "PETSC_DIR=%PETSC_DIR%SERIAL")
set PATH=%PATH%;"%PETSC_DIR%"
set PATH=%PATH%;"."
# Run tests
ctest.exe -C %BUILD_TYPE%