Skip to content
ocx
install

find_ocx

find_ocx runs pinned, sha256-verified tools such as jq or shellcheck from your CMake build, using the OCX package manager.

examples/project/CMakeLists.txt
# 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
)
Terminal window
cmake -S . -B build && cmake --build build

Run 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.