Skip to content
ocx
install

Update the vendored files

You copied ocx.cmake and Findocx.cmake into cmake/, and a later release has fixes or pins a later ocx. Copying the files by hand gives you no check that they arrived whole. Fetching them at configure time with no hash trusts the network on every build. The module can update itself in script mode and check both files against the SHA256SUMS fetched from the same host before it replaces anything.

You need network access to GitHub, or to a mirror of the release files. The commands below run in your project root.

Run cmake -P cmake/ocx.cmake. Script mode starts no project and writes no build cache. The module asks the GitHub releases API for the newest tag, downloads the files, verifies them and replaces both.

It prints one line with the old and the new version, for example -- find_ocx: 0.3.0 -> 0.4.0 (v0.4.0).

Pass the tag to move to a specific release, or to roll back. Run cmake -DOCX_SELF_UPDATE_VERSION=v0.4.0 -P cmake/ocx.cmake. The leading v is optional, and a lower tag is accepted because the printed line shows the direction.

Host the release files at <url>/<tag>/<filename> for ocx.cmake, Findocx.cmake and SHA256SUMS. Then run cmake -DOCX_SELF_UPDATE_VERSION=v0.4.0 -DOCX_SELF_UPDATE_URL=https://mirror.corp/find_ocx -P cmake/ocx.cmake.

A mirror cannot answer the releases API, so the version is required. Without it the update stops and names OCX_SELF_UPDATE_VERSION. A mirror that lacks the files fails like this:

find_ocx: failed to fetch http://mirror.corp/find_ocx/v0.4.0/SHA256SUMS: "HTTP response code said error"
hint: a mirror must allow anonymous read

The module fetches SHA256SUMS from the same mirror, so the check catches corruption and partial downloads but not a mirror that serves an altered pair. If you do not trust the mirror, compare its SHA256SUMS against the GitHub release, or verify the signed tag, before you commit.

The update downloads SHA256SUMS first and reads the hashes for both files. It downloads each file against its hash into a temporary directory next to the module. Only when both downloads match does it rename the files into place, so a failed update leaves your vendored copy untouched. A directory without Findocx.cmake is updated for ocx.cmake alone.

Look at the diff, because the release may pin a different ocx or change behaviour. Commit both files in one change. Update every vendored copy in the same change, because a configure that loads two copies at different versions stops with an error.