diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d2322e3..fcedccb4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,16 +4,27 @@ on: [push] jobs: ctest: - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: ["ubuntu-22.04", "macos-11", "ubuntu-20.04"] + fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: apt + if: ${{ runner.os == 'Linux' }} run: | sudo apt update sudo apt install liblapack-dev openmpi-bin libopenmpi-dev libscalapack-openmpi-dev + - name: brew + if: ${{ runner.os == 'macOS' }} + run: | + brew install openmpi scalapack libomp + - name: pip run: | python -m pip install numpy @@ -26,7 +37,13 @@ jobs: working-directory: ${{runner.workspace}}/build shell: bash run: | - cmake -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE + if [ ${{ runner.os }} = "macOS" ] ; then + # CONFIG=apple requires gfortran but macOS runner has not, but gfortran-11, 12, ... + ln -s `which gfortran-11` gfortran + env PATH=`pwd`:$PATH HOMEBREW_PREFIX=/usr/local cmake -DCONFIG=apple -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE + else + cmake -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE + fi - name: build working-directory: ${{runner.workspace}}/build diff --git a/config/apple.cmake b/config/apple.cmake index 9b197129..73082407 100644 --- a/config/apple.cmake +++ b/config/apple.cmake @@ -1,15 +1,19 @@ # for Apple clang compiler # additional libomp and gfortran installation required # mac computers are suggested to use this configuration for better performance + +if(NOT $ENV{HOMEBREW_PREFIX}) + message(FATAL "Homebrew is not installed. Please install Homebrew first.") +endif() + set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security") set(CMAKE_C_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas -Wno-logical-not-parentheses") -set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) +# set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) # OpenMP with libomp -set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/lib -lomp") -set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp" CACHE STRING "" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "-L$ENV{HOMEBREW_PREFIX}/opt/libomp/lib -lomp") +set(OpenMP_C_FLAGS "-I$ENV{HOMEBREW_PREFIX}/opt/libomp/include -Xpreprocessor -fopenmp" CACHE STRING "" FORCE) set(OpenMP_C_LIB_NAMES "") set(CMAKE_OSX_SYSROOT "") -