Skip to content

Commit 1663abb

Browse files
committed
Merge remote-tracking branch 'origin/245-fix-v1125-packaging-and-badge-cleanup' into staging
2 parents 9b13d51 + 5162dc8 commit 1663abb

3 files changed

Lines changed: 118 additions & 7 deletions

File tree

.github/workflows/package.yml

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ jobs:
8686

8787
- name: Configure
8888
run: |
89+
HDF5_PREFIX="$(brew --prefix hdf5)"
8990
cmake -B build \
9091
-DCMAKE_BUILD_TYPE=Release \
9192
-DCMAKE_INSTALL_PREFIX=/usr/local \
92-
-DHDF5_ROOT=$(brew --prefix hdf5) \
93+
-DHDF5_ROOT="$HDF5_PREFIX" \
94+
-DCMAKE_PREFIX_PATH="$HDF5_PREFIX" \
9395
-DH5CPP_BUILD_EXAMPLES=OFF \
9496
-DH5CPP_BUILD_TESTS=OFF \
9597
-DH5CPP_BUILD_BENCH=OFF
@@ -107,21 +109,100 @@ jobs:
107109
if-no-files-found: error
108110

109111
# ── Windows (NSIS .exe) ───────────────────────────────────────────────────────
112+
# No Chocolatey 'hdf5' package exists; mirror the build-from-source approach
113+
# from ci.yml. zlib is built fresh each run (~30s); HDF5 install prefix is
114+
# cached between runs.
110115
package-windows:
111116
name: windows / x64 / NSIS
112117
runs-on: windows-latest
118+
env:
119+
HDF5_VERSION: 1.12.2
120+
HDF5_CACHE_VERSION: v3
113121

114122
steps:
115123
- uses: actions/checkout@v4
116124

117-
- name: Install HDF5
118-
run: choco install hdf5 -y --no-progress
125+
- name: Build zlib from source
126+
shell: powershell
127+
run: |
128+
$ErrorActionPreference = "Stop"
129+
$zlib_version = "1.3.1"
130+
$zlib_archive = "$env:RUNNER_TEMP\zlib-$zlib_version.tar.gz"
131+
$zlib_source = "$env:RUNNER_TEMP\zlib-$zlib_version"
132+
$zlib_build = "$env:RUNNER_TEMP\zlib-build"
133+
$zlib_prefix = "$env:RUNNER_TEMP\zlib-install"
134+
135+
Invoke-WebRequest `
136+
-Uri "https://github.com/madler/zlib/archive/refs/tags/v$zlib_version.tar.gz" `
137+
-OutFile $zlib_archive
138+
tar -xzf $zlib_archive -C $env:RUNNER_TEMP
139+
140+
cmake -S $zlib_source -B $zlib_build `
141+
-G "Visual Studio 17 2022" -A x64 `
142+
-DCMAKE_INSTALL_PREFIX="$zlib_prefix"
143+
cmake --build $zlib_build --parallel --config Release
144+
cmake --install $zlib_build --config Release
145+
146+
- name: Restore HDF5 cache
147+
id: cache-hdf5
148+
uses: actions/cache/restore@v5
149+
with:
150+
path: ${{ runner.temp }}\hdf5-${{ env.HDF5_VERSION }}-install
151+
key: hdf5-windows-vs2022-${{ env.HDF5_VERSION }}-pkg-${{ env.HDF5_CACHE_VERSION }}
152+
153+
- name: Build HDF5 from source
154+
if: steps.cache-hdf5.outputs.cache-hit != 'true'
155+
shell: powershell
156+
run: |
157+
$ErrorActionPreference = "Stop"
158+
$hdf5_version = "${{ env.HDF5_VERSION }}"
159+
$hdf5_archive = "$env:RUNNER_TEMP\hdf5-$hdf5_version.tar.gz"
160+
$hdf5_source = "$env:RUNNER_TEMP\hdf5-$hdf5_version"
161+
$hdf5_build = "$env:RUNNER_TEMP\hdf5-$hdf5_version-build"
162+
$hdf5_prefix = "$env:RUNNER_TEMP\hdf5-$hdf5_version-install"
163+
164+
Invoke-WebRequest `
165+
-Uri "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-$hdf5_version/src/hdf5-$hdf5_version.tar.gz" `
166+
-OutFile $hdf5_archive
167+
tar -xzf $hdf5_archive -C $env:RUNNER_TEMP
168+
169+
cmake -S $hdf5_source -B $hdf5_build `
170+
-G "Visual Studio 17 2022" -A x64 `
171+
-DCMAKE_INSTALL_PREFIX="$hdf5_prefix" `
172+
-DHDF_CFG_NAME=Release `
173+
-DBUILD_SHARED_LIBS=ON `
174+
-DBUILD_TESTING=OFF `
175+
-DHDF5_BUILD_TOOLS=OFF `
176+
-DHDF5_BUILD_UTILS=OFF `
177+
-DHDF5_BUILD_EXAMPLES=OFF `
178+
-DHDF5_BUILD_CPP_LIB=OFF `
179+
-DHDF5_BUILD_HL_LIB=OFF `
180+
-DHDF5_BUILD_FORTRAN=OFF `
181+
-DHDF5_ENABLE_Z_LIB_SUPPORT=ON `
182+
-DHDF5_ENABLE_SZIP_SUPPORT=OFF `
183+
-DZLIB_USE_EXTERNAL=OFF `
184+
-DZLIB_INCLUDE_DIR="$env:RUNNER_TEMP/zlib-install/include" `
185+
-DZLIB_LIBRARY="$env:RUNNER_TEMP/zlib-install/lib/zlib.lib"
186+
187+
cmake --build $hdf5_build --parallel --config Release
188+
cmake --install $hdf5_build --config Release
189+
190+
- name: Save HDF5 cache
191+
if: steps.cache-hdf5.outputs.cache-hit != 'true'
192+
uses: actions/cache/save@v5
193+
with:
194+
path: ${{ runner.temp }}\hdf5-${{ env.HDF5_VERSION }}-install
195+
key: ${{ steps.cache-hdf5.outputs.cache-primary-key }}
119196

120197
- name: Configure
121198
shell: pwsh
122199
run: |
200+
$hdf5_prefix = "$env:RUNNER_TEMP/hdf5-${{ env.HDF5_VERSION }}-install"
201+
$zlib_prefix = "$env:RUNNER_TEMP/zlib-install"
123202
cmake -B build `
124203
-DCMAKE_BUILD_TYPE=Release `
204+
-DHDF5_ROOT="$hdf5_prefix" `
205+
-DCMAKE_PREFIX_PATH="$hdf5_prefix;$zlib_prefix" `
125206
-DH5CPP_BUILD_EXAMPLES=OFF `
126207
-DH5CPP_BUILD_TESTS=OFF `
127208
-DH5CPP_BUILD_BENCH=OFF `

CMakeLists.txt

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,24 @@ if(APPLE)
1212
set(CMAKE_OSX_DEPLOYMENT_TARGET "14.4" CACHE STRING "Minimum macOS deployment version")
1313
endif()
1414

15-
project(libh5cpp-dev VERSION 1.10.4.6 LANGUAGES CXX C)
15+
# Derive package version from the latest git tag before project(), so CPack
16+
# embeds it as PROJECT_VERSION rather than a stale hardcoded number. Falls
17+
# back to a placeholder when building from a tarball without git history.
18+
find_package(Git QUIET)
19+
set(H5CPP_PROJECT_VERSION "1.12.0")
20+
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
21+
execute_process(
22+
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --match "v[0-9]*"
23+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
24+
OUTPUT_VARIABLE H5CPP_GIT_TAG
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
ERROR_QUIET)
27+
if(H5CPP_GIT_TAG MATCHES "^v([0-9]+(\\.[0-9]+)*)$")
28+
set(H5CPP_PROJECT_VERSION "${CMAKE_MATCH_1}")
29+
endif()
30+
endif()
31+
32+
project(libh5cpp-dev VERSION ${H5CPP_PROJECT_VERSION} LANGUAGES CXX C)
1633

1734
# ─── Standard Settings ────────────────────────────────────────────────────────────
1835
set(CMAKE_CXX_STANDARD 20)
@@ -90,9 +107,15 @@ find_package(Threads REQUIRED QUIET)
90107
# ─── HDF5 ─────────────────────────────────────────────────────────────────────────
91108
find_package(HDF5 REQUIRED COMPONENTS C)
92109

93-
if(HDF5_VERSION VERSION_LESS ${H5CPP_BASE_VERSION})
110+
# HDF5 floor is decoupled from h5cpp package version. Previously the check
111+
# compared HDF5_VERSION against PROJECT_VERSION, which coupled package
112+
# versioning to HDF5 minimums by coincidence. After #234 raised the floor
113+
# to 1.12 and #247 made PROJECT_VERSION track the git tag, the comparison
114+
# stopped being meaningful. Pin the floor explicitly.
115+
set(H5CPP_HDF5_FLOOR "1.12.0")
116+
if(HDF5_VERSION VERSION_LESS ${H5CPP_HDF5_FLOOR})
94117
message(FATAL_ERROR
95-
"-- !!! H5CPP examples require HDF5 v${H5CPP_BASE_VERSION} or greater !!!"
118+
"-- !!! H5CPP requires HDF5 v${H5CPP_HDF5_FLOOR} or greater (found ${HDF5_VERSION}) !!!"
96119
)
97120
else()
98121
message(STATUS
@@ -382,6 +405,14 @@ set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
382405
# productbuild (macOS .pkg)
383406
set(CPACK_PRODUCTBUILD_IDENTIFIER "org.h5cpp.h5cpp")
384407

408+
# Override the default per-generator filename so that amd64 / arm64 / x86_64 /
409+
# aarch64 / darwin-arm64 / windows-amd64 produce distinct names when collected
410+
# into a single release upload directory. Without this, multi-arch CI matrix
411+
# builds emit identical filenames and overwrite each other on the Release page.
412+
set(CPACK_PACKAGE_FILE_NAME
413+
"${CPACK_PACKAGE_NAME}-v${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
414+
string(TOLOWER "${CPACK_PACKAGE_FILE_NAME}" CPACK_PACKAGE_FILE_NAME)
415+
385416
include(CPack)
386417

387418
# ─── Developer convenience targets ───────────────────────────────────────────

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20123216.svg)](https://doi.org/10.5281/zenodo.20123216)
77
[![GitHub release](https://img.shields.io/github/v/release/vargalabs/h5cpp.svg)](https://github.com/vargalabs/h5cpp/releases)
88
[![Documentation](https://img.shields.io/badge/docs-stable-blue)](https://vargalabs.github.io/h5cpp)
9-
[![Downloads](https://img.shields.io/github/downloads/vargalabs/h5cpp/total)](https://github.com/vargalabs/h5cpp/releases)
109

1110
# H5CPP — High-Performance [HDF5][hdf5] for Modern C++
1211

0 commit comments

Comments
 (0)