- integrations
- find_ocx
find_ocx
find_ocx runs pinned, sha256-verified tools such as jq or shellcheck from your CMake build, using the OCX package manager.
# The ocx.toml next to this file is found by the upward search; the lock# is verified; nothing is pulled yet (lazy). NAME picks the prefix of the# result variables: NAME TOOLS -> OCX_TOOLS_RUN, OCX_TOOLS_RUN_JQ# (defaults to PROJECT -> OCX_PROJECT_RUN).ocx_project(NAME TOOLS BINS jq)
# Build-time tool use, lazily materialized on first execution. Generator# expressions compose naturally - the command is a plain CMake list.add_custom_target(validate ALL COMMAND ${OCX_TOOLS_RUN} jq -n -e --arg config "$<CONFIG>" [[$config | length >= 0]] VERBATIM)cmake -S . -B build && cmake --build buildRun jq in a CMake build walks through this example step by step.
You need CMake 3.19 and network access or a mirror.
You do not need to install ocx.
An ocx on PATH is used when present, otherwise the pinned CLI is bootstrapped on first configure into a per-machine cache.
Findocx.cmake alone works on CMake 3.15.
Pick a goal
Section titled “Pick a goal”- Run workspace tools from ocx.toml: launchers, groups and generator expressions
- Pin and freeze tag resolution: an index snapshot or per-platform digests
- Use find_package with find_ocx: find the CLI, or search a pulled package
- Reproduce the build in CI: Linux, macOS and Windows with one configuration
- Build behind a mirror or offline: mirrors, credentials and no downloads
- Cross-build with foreign-platform content: content for a platform other than the host
- Update the vendored files: refresh
ocx.cmakeandFindocx.cmake - Fix a failing configure: nested builds, floating tags and stale locks
Understand it
Section titled “Understand it”Look it up
Section titled “Look it up”- Commands, variables and Findocx.cmake
- Examples: the four tested projects in
examples/