From b15f2dbc2941fad49fdc0d9e9e7ebe9ec6fc4595 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:28:29 -0500 Subject: [PATCH] Add msys2 workflow for CMake (#4991) Also updates CMake configure checks to build HDF5 w/ MSYS2 --- .github/workflows/cmake.yml | 16 ++++-- .github/workflows/msys2-cmake.yml | 91 ++++++++++++++++++++++++++++++ config/cmake/ConfigureChecks.cmake | 9 ++- release_docs/RELEASE.txt | 12 ++++ 4 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/msys2-cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d57978d5fcc..cd941e6a7a1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -109,8 +109,14 @@ jobs: name: "CMake TestExpress Workflows" uses: ./.github/workflows/testxpr-cmake.yml -# call-release-cmake-julia: -# name: "CMake Julia Workflows" -# uses: ./.github/workflows/julia-cmake.yml -# with: -# build_mode: "Release" + # call-release-cmake-julia: + # name: "CMake Julia Workflows" + # uses: ./.github/workflows/julia-cmake.yml + # with: + # build_mode: "Release" + + call-release-cmake-msys2: + name: "CMake Msys2 Workflows" + uses: ./.github/workflows/msys2-cmake.yml + with: + build_mode: "Release" \ No newline at end of file diff --git a/.github/workflows/msys2-cmake.yml b/.github/workflows/msys2-cmake.yml new file mode 100644 index 00000000000..7cbd7890f1c --- /dev/null +++ b/.github/workflows/msys2-cmake.yml @@ -0,0 +1,91 @@ +name: hdf5 dev CMake MSys2 CI + +# Triggers the workflow on a call from another workflow +on: + workflow_call: + inputs: + build_mode: + description: "release vs. debug build" + required: true + type: string + +permissions: + contents: read + +jobs: + + CMake_build_and_test: + + # The type of runner that the job will run on + runs-on: windows-latest + strategy: + matrix: + include: + - { icon: '⬛', sys: mingw32 } + - { icon: '🟦', sys: mingw64 } + - { icon: '🟨', sys: ucrt64 } + - { icon: '🟧', sys: clang64 } + name: ${{ matrix.icon }} MSYS2-${{ matrix.sys }}-${{ inputs.build_mode }} + defaults: + run: + shell: msys2 {0} + + steps: + - name: '${{ matrix.icon }} Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + base-devel + git + gcc + make + development + pacboy: >- + toolchain:p + cmake:p + ninja:p + + - name: Set git to use LF + run: | + git config --global core.autocrlf input + + - name: Get Sources + uses: actions/checkout@v4.1.1 + + - name: CMake Configure + run: | + mkdir "${{ runner.workspace }}/build" + cd "${{ runner.workspace }}/build" + cmake -C $GITHUB_WORKSPACE/config/cmake/cacheinit.cmake \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=${{ inputs.build_mode }} \ + -DCMAKE_TOOLCHAIN_FILE="" \ + -DHDF5_GENERATE_HEADERS=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DHDF5_ENABLE_ALL_WARNINGS=ON \ + -DHDF5_ENABLE_PARALLEL:BOOL=OFF \ + -DHDF5_BUILD_CPP_LIB:BOOL=OFF \ + -DHDF5_BUILD_FORTRAN=OFF \ + -DHDF5_BUILD_JAVA=OFF \ + -DHDF5_BUILD_DOC=OFF \ + -DLIBAEC_USE_LOCALCONTENT=OFF \ + -DZLIB_USE_LOCALCONTENT=OFF \ + $GITHUB_WORKSPACE + + - name: CMake Build + run: | + cmake --build . --parallel 3 --config ${{ inputs.build_mode }} + working-directory: ${{ runner.workspace }}/build + + - name: CMake Run Tests + run: | + ctest . --parallel 2 -C ${{ inputs.build_mode }} -V -E "tfloatsattrs|testhdf5-base|cache_api|dt_arith|H5TEST-dtypes|err_compat" + working-directory: ${{ runner.workspace }}/build + + - name: CMake Run Expected to Fail Tests + run: | + ctest . --parallel 2 -C ${{ inputs.build_mode }} -V -R "tfloatsattrs|testhdf5-base|cache_api|dt_arith|H5TEST-dtypes|err_compat" + working-directory: ${{ runner.workspace }}/build + continue-on-error: true diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index df6c760f0cc..ed53feae60b 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -140,7 +140,7 @@ else () set(C_INCLUDE_QUADMATH_H 0) endif () -if (CYGWIN) +if (MINGW OR CYGWIN) set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE") add_definitions ("-D_GNU_SOURCE") endif () @@ -399,7 +399,12 @@ endif () #----------------------------------------------------------------------------- # Check for some functions that are used # -CHECK_FUNCTION_EXISTS (alarm ${HDF_PREFIX}_HAVE_ALARM) +if (NOT MINGW) + # alarm(2) support is spotty in MinGW, so assume it doesn't exist + # + # https://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00040.html + CHECK_FUNCTION_EXISTS (alarm ${HDF_PREFIX}_HAVE_ALARM) +endif () CHECK_FUNCTION_EXISTS (fcntl ${HDF_PREFIX}_HAVE_FCNTL) CHECK_FUNCTION_EXISTS (flock ${HDF_PREFIX}_HAVE_FLOCK) CHECK_FUNCTION_EXISTS (fork ${HDF_PREFIX}_HAVE_FORK) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 897adaf039f..1545bdc4402 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,6 +47,18 @@ New Features Configuration: ------------- + - Added support for MinGW + MSYS2 when building with CMake + + We previously added support for this to the Autotools and the appropriate + configure-time checks have been added to CMake. + + CMake + MinGW + MSYS2 is now tested with the following environments: + + * mingw32 + * mingw64 + * ucrt64 + * clang64 + - Added CMake build mode flags to the libhdf5.settings file Flags from the CMake build mode (e.g., optimization) are not a part of