Skip to content

feat: WIP - Implement the infrastructure to allow OpenRV to find dependencies#1205

Closed
cedrik-fuoco-adsk wants to merge 15 commits intoAcademySoftwareFoundation:mainfrom
cedrik-fuoco-adsk:SG-42387-find
Closed

feat: WIP - Implement the infrastructure to allow OpenRV to find dependencies#1205
cedrik-fuoco-adsk wants to merge 15 commits intoAcademySoftwareFoundation:mainfrom
cedrik-fuoco-adsk:SG-42387-find

Conversation

@cedrik-fuoco-adsk
Copy link
Copy Markdown
Contributor

Linked issues

Summarize your change.

Describe the reason for the change.

Describe what you have tested and on which operating system.

Add a list of changes, and note any that might need special attention during the review.

If possible, provide screenshots.

PCRE2: Switch from autotools to CMake-based ExternalProject_Add.
Update library naming from MinGW format to MSVC format. Handle
PCRE2's internal debug postfix 'd' for Debug builds. Use
RV_ADD_IMPORTED_LIBRARY and RV_STAGE_DEPENDENCY_LIBS macros.

Atomic Ops: Use CMake build on all platforms, removing the
autotools path (sh/autogen.sh, sh/configure, make). Use portable
library naming via CMAKE_STATIC_LIBRARY_PREFIX/SUFFIX.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
@cedrik-fuoco-adsk cedrik-fuoco-adsk changed the title WIP - Sg 42387 find feat: Allow OpenRV to find dependencies Mar 20, 2026
@cedrik-fuoco-adsk cedrik-fuoco-adsk changed the title feat: Allow OpenRV to find dependencies feat: WIP - Allow OpenRV to find dependencies Mar 20, 2026
@cedrik-fuoco-adsk cedrik-fuoco-adsk force-pushed the SG-42387-find branch 2 times, most recently from 3f9da71 to d3c4804 Compare March 20, 2026 16:33
@cedrik-fuoco-adsk cedrik-fuoco-adsk changed the title feat: WIP - Allow OpenRV to find dependencies feat: WIP - Implement the infrastructure to allow OpenRV to find dependencies Mar 20, 2026
@mcoliver
Copy link
Copy Markdown
Contributor

@cedrik-fuoco-adsk Saw you were working on this. I have been sitting on #1207 for a few months as it is dependent on a couple outstanding PR's that are waiting to be merged (having iotiff use public headers and the oiio 2->3 upgrade (1176 1087 don't want to link them here to muddy your PR). But perhaps my work is interesting to the work you are doing here. It is also non-destructive to the current build process so would love to see it merged. Builds OpenRV in 6 minutes on my macbook air with all the latest packages :D Experimental of course.

…d dispatcher

Add RV_FIND_DEPENDENCY macro with CONFIG and pkg_config fallback
strategies. Refactor dav1d as the first dependency using the new
dispatcher pattern, with pkg_config support for libraries that
don't ship CMake config files.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Refactor Imath to use the find_package CONFIG dispatcher pattern.
Add RV_DEPS_VERSION_MATCH and per dependency RV_DEPS_<TARGET>_VERSION_MATCH
options to control EXACT vs MINIMUM version matching behavior.
Improve diagnostic messages to include version and verbose output
when a package is not found.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…h contamination

Refactor Boost to the find first dispatcher pattern: prefer an installed
Boost (e.g. Homebrew) via find_package(CONFIG COMPONENTS ...) and fall
back to building from source. Extract ExternalProject_Add build logic
into cmake/dependencies/build/boost.cmake.

RV_FIND_DEPENDENCY gains a COMPONENTS parameter to forward component
lists to find_package.

Fix a critical include path contamination issue on macOS with Homebrew.
CMake normalizes ".." before resolving symlinks, so walking up from a
symlinked config dir lands on the shared prefix (/opt/homebrew) instead
of the Cellar root. This caused unrelated Homebrew headers to leak into
compilation commands. RV_SET_FOUND_PACKAGE_DIRS now resolves symlinks
before walking up. RV_FIND_DEPENDENCY replaces stale include dirs on
imported targets. boost.cmake fixes Boost::headers specifically.

RV_STAGE_DEPENDENCY_LIBS gains TARGET_LIBS for staging via generator
expressions, with make_directory to ensure destination dirs exist and
VERBATIM to prevent shell metacharacter misinterpretation.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…xup for auxiliary targets

Refactor OpenEXR to the find first dispatcher pattern: prefer an
installed OpenEXR via find_package(CONFIG) and fall back to building
from source. Extract ExternalProject_Add build logic into
cmake/dependencies/build/openexr.cmake.

Fix the symlink include path fixup to cover ALL imported targets from a
package, not just DEPS_LIST_TARGETS. Config files often create auxiliary
interface targets (e.g. Imath::ImathConfig, OpenEXR::OpenEXRConfig) that
carry include directories and are linked transitively. The fix now
queries IMPORTED_TARGETS from the directory scope and fixes any target
matching the package prefix. Also warns if IMPORTED_TARGETS is empty.

Fix double prefix bug in per dependency version match and force build
variable names: RV_DEPS_${_RFD_TARGET}_VERSION_MATCH expanded to
RV_DEPS_RV_DEPS_OPENEXR_VERSION_MATCH since _RFD_TARGET already
contains the RV_DEPS_ prefix.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Refactor GLEW to the find first dispatcher pattern: prefer an installed
GLEW via find_package(CONFIG) and fall back to building from source
with the existing Makefile based ExternalProject_Add.

Extract Makefile build logic into cmake/dependencies/build/glew.cmake.

GLEW's CMake config does not ship a version file, so VERSION is omitted
from the RV_FIND_DEPENDENCY call to avoid find_package failure. The
config file automatically creates GLEW::GLEW as a copy of GLEW::glew.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Refactor zlib to the find first dispatcher pattern: prefer an installed
zlib via find_package(MODULE) or pkg-config and fall back to building
from source. Extract ExternalProject_Add build logic into
cmake/dependencies/build/zlib.cmake.

RV_FIND_DEPENDENCY gains ALLOW_MODULE to try CMake built-in Find modules
(e.g. FindZLIB.cmake) as a strategy between CONFIG and pkg-config.
Add RV_SET_FOUND_MODULE_DIRS to derive directory variables from MODULE
mode results.

Enable PKG_CONFIG_USE_CMAKE_PREFIX_PATH temporarily during pkg-config
fallback so CMAKE_PREFIX_PATH hints expose .pc files to pkg-config.

Track contaminating prefixes detected during symlink resolution in
RV_DEPS_IGNORE_PREFIXES (CACHE INTERNAL) so ExternalProject sub-builds
can react to Homebrew include path contamination.

Fix variable shadowing bug in RV_SET_FOUND_PACKAGE_DIRS,
RV_SET_FOUND_PKGCONFIG_DIRS, and RV_SET_FOUND_MODULE_DIRS: the regular
variable set by RV_CREATE_STANDARD_DEPS_VARIABLES shadowed the CACHE
INTERNAL variable, causing downstream code to read stale ExternalProject
install paths instead of the resolved found-package paths.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…tion

Fix OIIO ExternalProject sub-build failing with undefined
boost::filesystem symbols due to Homebrew include path contamination.

When deps like Imath and fmt come from Homebrew, their transitive
-isystem /opt/homebrew/include pulls in newer Boost headers (with _v3
namespaced symbols) that appear before RV's Boost 1.82 headers in the
include order, causing ABI mismatches at link time.

Fix by adding RV's Boost include directory as a non-system -I flag in
the OIIO sub-build when contaminating prefixes are detected. Compilers
always search -I before -isystem, ensuring the correct Boost headers
are found.

Replace fragile GET_TARGET_PROPERTY(IMPORTED_LOCATION) Imath resolution
with direct *_DIR variables from RV_DEPS_*_ROOT_DIR, which work for
both built-from-source and found (e.g. Homebrew) packages.

Fix typo: -USE_FFMPEG=0 -> -DUSE_FFMPEG=0.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Add ADD_DEPENDENCIES(${arg_TARGET} dependencies) to all plugin type
handlers in rv_stage.cmake (IMAGE_FORMAT, MOVIE_FORMAT, OIIO_PLUGIN,
OUTPUT_PLUGIN, MU_PLUGIN, PYTHON_PLUGIN).

CMake's ADD_DEPENDENCIES on IMPORTED targets is not transitive, so
plugin targets that transitively link against ExternalProject outputs
(e.g. libpython3.11.dylib via Python::Python) had no build-order
guarantee that the ExternalProject had completed. This caused
intermittent link failures in parallel builds when some deps resolve
instantly via find_package instead of building from source, shifting
the ninja schedule.

The EXECUTABLE and EXECUTABLE_WITH_PLUGINS types already had this
dependency. Plugins were missing it.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…l detection issue on MSVC. Although, I am not sure why this appeared just now

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Refactor openssl.cmake to use the find-first dispatcher pattern:
- RV_FIND_DEPENDENCY with ALLOW_MODULE and PKG_CONFIG_NAME for
  CONFIG → MODULE (FindOpenSSL) → pkg-config resolution
- Extract ExternalProject_Add build logic into build/openssl.cmake
- Preserve RHEL8/CY2023 system OpenSSL 1.1.1 path
- Use TARGET_LIBS for found-package staging
- Linux OpenSSL/ subdirectory isolation for RHEL ABI compatibility
- Shared naming logic for both found and built paths

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Replace USE_FLAG_FILE with proper output tracking for TARGET_LIBS:
the staging macro now resolves IMPORTED_LOCATION at configure time to
derive output filenames, so Ninja detects deleted staged files and
re-runs the staging command automatically. Falls back to flag file
if location cannot be resolved.

Also convert dav1d, ffmpeg, and ocio from LIB_DIR copy-directory
staging to TARGET_LIBS for the same incremental-build benefit.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Fix two build regressions introduced by the find_package dispatcher work:

1. OCIO Windows staging: RV_MAKE_STANDARD_LIB_NAME generates
   "OpenColorIO.dll" but OCIO builds "OpenColorIO_2.3.dll" (version-
   suffixed). Fix _libpath to match the actual DLL so TARGET_LIBS
   staging resolves the correct file.

2. OIIO/OCIO Imath_DIR: hardcoded lib/cmake/Imath is wrong on
   RHEL/Rocky Linux where GNUInstallDirs sets LIBDIR to lib64.
   Use RV_DEPS_IMATH_CMAKE_DIR (set in imath.cmake from _lib_dir)
   which correctly resolves to lib64/cmake/Imath on RHEL.
   The broken Imath_DIR caused find_dependency(Imath) inside
   OpenEXRConfig.cmake to fail, surfacing as "OpenEXR not found"
   in the OIIO sub-build.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Move all install_name_tool modifications and codesigning of staged
libraries from build time to install time. This prevents Homebrew
library signatures from being invalidated during the build, which
causes SIGKILL on arm64 macOS and EPERM from install_name_tool on
macOS 26+.

Build-time changes:
- Remove install_name_tool -id and codesign from TARGET_LIBS staging
- Remove install_name_tool -change POST_BUILD on executables/plugins
- Replace install_name_tool -add_rpath POST_BUILD with linker flags
  (TARGET_LINK_OPTIONS) to avoid post-link binary modification
- Remove RV_RESOLVE_DARWIN_INSTALL_NAME infrastructure (no longer needed)
- Remove install_name_tool -id from zlib found/built staging paths
- Add SONAME symlink creation for staged libraries whose install name
  differs from their filename (e.g. libFoo.2.3.dylib -> libFoo.2.3.2.dylib)

Install-time changes (remove_absolute_rpath.py):
- Add library self-ID fixup (install_name_tool -id @rpath/<name>)
- Broaden reference matching to convert all non-system absolute paths
  to @rpath (not just paths under source root)
- Add is_system_library() to preserve /usr/lib/ and /System/ refs
- Fix pre-existing bug: file._str.find() -> file.find()

Install-time changes (pre_install_darwin.cmake):
- Add ad-hoc codesign pass after rpath fixup for OpenRV
- Commercial RV replaces these via garasign in a separate pipeline stage

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
The TARGET_LIBS staging path only created SONAME symlinks on macOS
(via otool -D). On Linux, versioned libraries like
libOpenColorIO.so.2.3.2 were staged without the SONAME symlink
(libOpenColorIO.so.2.3), causing all LoadingSharedLibrariesTest
tests to fail with 'cannot open shared object file'.

Extend create_soname_symlink.cmake to support Linux by using
readelf -d to extract the ELF SONAME, and invoke the script on
Linux in addition to macOS. Platform is passed via -DRV_TARGET_*
flags to the cmake -P invocation.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants