Skip to content
ocx
install

find_ocx

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

CMakeLists.txt
cmake_minimum_required(VERSION 3.25...4.4)
project(hello_jq LANGUAGES NONE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ocx)
ocx_project(NAME TOOLS BINS jq)
add_custom_target(show_jq ALL COMMAND ${OCX_TOOLS_RUN} jq --version VERBATIM)

A build that needs jq usually says “install jq first” in its README. Or it calls find_program and takes whatever the host has. Every machine then runs its own version.

FetchContent and CPM fetch sources to compile. The vcpkg and Conan clients must be installed and configured before the build starts. With find_ocx, a prebuilt tool runs at the digest your ocx.lock fixes, on every machine.

Run jq in a CMake build is the shortest path to a first result.

This documentation is for CMake authors and the platform engineers who run their builds.