AcademySoftwareFoundation / OpenTimelineIO

Open Source API and interchange format for editorial timeline information.
http://opentimeline.io
Apache License 2.0
1.48k stars 294 forks source link

Unable to link with downstream project libraries that are not exported #910

Open rogernelson opened 3 years ago

rogernelson commented 3 years ago

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

ssteinbach commented 3 years ago

@rogernelson is this still an issue with the reworked cmake system?