AcademySoftwareFoundation / AcademySoftwareFoundation/OpenTimelineIO
Unable to link with downstream project libraries that are not exported
- Dominant language
- C++
- Stars
- 2k
- Forks
- 351
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 1
Description
## Bug Report
### Build Problem
If trying to link with a downstream project that does not export its libraries (Imath in this example) this will occur when building:
```
-- OTIO Defaulting C++ install to
-- Building shared libs
-- Installing C++ bindings to: /opentimelineio/cxx-sdk
-- Installing C++ dynamic libraries to: /opentimelineio
-- Installing 'any' and 'nonstd' for C++ (OTIO_DEPENDENCIES_INSTALL=ON)
-- Installing Python bindings to:
-- Building C++ with Coverage: OFF
-- Checking git repo is available:
true
-- root: Updating git submodules to make sure they are up to date
-- pybind11 v2.3.dev0
-- Configure Imath Version: 3.0.0 Lib API: 26.0.0
-- Imath is configuring as a cmake sub project
-- Configuring done
CMake Error in src/opentimelineio/CMakeLists.txt:
export called with target "opentimelineio" which requires target "Imath"
that is not in any export set.
```
## Additional Context
This occurs because opentime and opentimelineio call export in their CMakeFiles like this:
```
export(TARGETS opentimelineio
NAMESPACE OTIO::
FILE "${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfig.cmake")
```
When exporting, all the dependencies must also be exported. Meaning that opentimelineio and opentimeio will not be able to link with any downstream projects that do not also export.
From the CMake docs:
> Creates a file that may be included by outside projects to import targets from the current project's build tree. This is useful during cross-compiling to build utility executables that can run on the host platform in one project and then import them into another project being compiled for the target platform. If the NAMESPACE option is given the string will be prepended to all target names written to the file.
Target installations are associated with the export using the EXPORT option of the install(TARGETS) command.
It's not likely that any upstream project would ever need to reference the libraries directly from the build tree. In fact, its likely undesirable since this is most often a temporary location. Upstream projects would instead want to access the installed location created by the `install( EXPORT )` command, which is also present in the CMakeFiles already.
This seems to have been added to support a local pip install, so any solution should make sure that it is still possible to call `pip install .`.
Contributor guide
Research direction
Start in src/opentimelineio/CMakeLists.txt and inspect the export(TARGETS) call alongside the existing install(EXPORT) setup. Reproduce the configuration with a downstream library that is not exported, then verify that the build no longer requires that dependency to be exported and that pip install . still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100