Skip to content
ocx
install

Findocx.cmake

Reference for the Findocx find module. This page is generated from the .rst block in Findocx.cmake.

Finds the OCX CLI and provides it as an imported target. The module is written to work standalone on CMake 3.15 or later, but the tests run it on 3.25 and later only. The provisioning commands ocx_project and ocx_package live in ocx.cmake, which you add with include(ocx).

find_package(ocx [<version>] [REQUIRED])

Both entry points resolve OCX_EXECUTABLE, then PATH, then the pinned bootstrap. They differ only in the bootstrap default. This module opts in, because find modules discover. ocx.cmake opts out, and OFF forbids the implicit download there.

ocx::ocx

Imported executable target for OCX_EXECUTABLE.

ocx_FOUND, OCX_FOUND

True when the ocx CLI is found and satisfies the requested version.

OCX_EXECUTABLE

Path of the ocx CLI. It is a cache variable and also the search hint. A path that does not exist, and an ocx that fails ocx version, count as not found.

OCX_VERSION_STRING

Version that ocx version reports.

OCX_EXECUTABLE

Set it to use a specific binary, for example one that ocx_bootstrap provides.

OCX_BOOTSTRAP

ON bootstraps the pinned ocx when none is found. ALWAYS skips the PATH search and always uses the pin. Both values need CMake 3.25 and an ocx.cmake next to Findocx.cmake. Empty or unset means OFF, and a value other than ON, OFF or ALWAYS is an error.

Changed in version 0.4. The bootstrap requires CMake 3.25. Release 0.3 required CMake 3.19.

The tested project examples/find_package finds the ocx CLI. Configure it with -DOCX_BOOTSTRAP=ON to bootstrap the pin when none is found.

find_package(ocx REQUIRED)
message(STATUS "example: ocx ${OCX_VERSION_STRING} at ${OCX_EXECUTABLE}")