Skip to content

[BUG] depthai-core 'BUILD_SHARED_LIBS=OFF' targets not found: 'fmt::fmt' in 'depthai::core', 'protobuf::libprotobuf' in 'depthai::messages', 'websocketpp::websocketpp' in 'depthai::foxglove_websocket' #1397

@marc-medley

Description

@marc-medley

Check if issue already exists

  • [BUG] Cannot configure project without USB support #1386, which uses -D'BUILD_SHARED_LIBS=false', is specific to USB support lacking a usb-1.0Config.cmake or usb-1.0-config.cmake file.
  • Other luxonis/depthai-core open issues are in the context of BUILD_SHARED_LIBS being enabled, and thus not applicable.

Describe the bug

The link phase of a consuming CMake project fails because depthai-core does not provide three targets which are indicated to be present based on lib/cmake/depthai/depthaiTargets.cmake:

  • depthai::core is missing fmt::fmt
  • depthai::messages is missing protobuf::libprotobuf
  • depthai::foxglove_websocket is missing websocketpp::websocketpp

Minimal Reproducible Example

Step 1. Build depthai-core with -DBUILD_SHARED_LIBS=OFF

The variable DEPTHAI_CORE_PATH points to the depthai-core which is build with -DBUILD_SHARED_LIBS=OFF. This path can be adjusted as needed.

DEPTHAI_CORE_VERSION="3.0.0-rc.3-static"
DEPTHAI_CORE_BRANCH="main"
DEPTHAI_CORE_PATH="/opt/luxonis/depthai-core/${DEPTHAI_CORE_VERSION}"

git clone \
    --single-branch \
    --branch ${DEPTHAI_CORE_BRANCH} \
    --recurse-submodules \
    [email protected]:luxonis/depthai-core.git \
    depthai_${DEPTHAI_CORE_VERSION}
cd depthai_${DEPTHAI_CORE_VERSION}

mkdir build && cd build

cmake -S .. -B . \
    -DDEPTHAI_BUILD_EXAMPLES=OFF \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_INSTALL_PREFIX="${DEPTHAI_CORE_PATH}"

if [[ "$(uname)" == "Darwin" ]]; then
  NUM_CORES=$(sysctl -n hw.ncpu)
else
  NUM_CORES=$(nproc)
fi
cmake --build . --parallel ${NUM_CORES};
cmake --build . --target install

Step 2. Configure and build a cmake project which consumes depthai-core

set(DEPTHAI_CORE_VERSION 3.0.0-rc.3-static)

list(APPEND
    CMAKE_PREFIX_PATH 
        "/opt/luxonis/depthai-core/${DEPTHAI_CORE_VERSION}"
)

find_package(depthai CONFIG REQUIRED)

target_link_libraries(example_app
    PRIVATE
        # ...
        depthai::core
    PUBLIC
        ${OpenCV_LIBS}
)

Step 3. The linker discovers that depthai-core is missing targets which are declared in lib/cmake/depthai/depthaiTargets.cmake to be present, but are not found.

Three targets in particular are stated to be present but found to be missing:

  • depthai::core is missing the declared fmt::fmt (depthaiTargets.cmake:87)
  • depthai::messages is missing the declared protobuf::libprotobuf (depthaiTargets.cmake:118)
  • depthai::foxglove_websocket is missing the declared websocketpp::websocketpp (depthaiTargets.cmake:126)

console output

All three errors have this message pattern:

CMake Error at /opt/luxonis/depthai-core/3.0.0-rc.3/lib/cmake/depthai/depthaiTargets.cmake:87 (set_target_properties):
  The link interface of target "depthai::core" contains:

    fmt::fmt

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

/depthaiTargets.cmake:87

set_target_properties(depthai::core PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "DEPTHAI_TARGET_CORE;DEPTHAI_TARGET_OPENCV;DEPTHAI_HAVE_OPENCV_SUPPORT;DEPTHAI_MERGED_TARGET;MCAP_STATIC;DEPTHAI_ENABLE_PROTOBUF;DEPTHAI_XTENSOR_SUPPORT"
  INTERFACE_COMPILE_FEATURES "cxx_std_17"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/"
  INTERFACE_LINK_LIBRARIES "opencv_core;opencv_imgproc;opencv_videoio;opencv_highgui;\$<LINK_ONLY:depthai::depthai-resources>;depthai::nlohmann_json;depthai::libnop;depthai::XLinkPublic;\$<LINK_ONLY:fmt::fmt>;\$<LINK_ONLY:yaml-cpp::yaml-cpp>;\$<LINK_ONLY:spdlog::spdlog>;\$<LINK_ONLY:depthai::XLink>;\$<LINK_ONLY:Threads::Threads>;\$<LINK_ONLY:BZip2::BZip2>;\$<LINK_ONLY:LibArchive::LibArchive>;\$<LINK_ONLY:ZLIB::ZLIB>;\$<LINK_ONLY:httplib::httplib>;\$<LINK_ONLY:semver::semver>;\$<LINK_ONLY:magic_enum::magic_enum>;\$<LINK_ONLY:liblzma::liblzma>;\$<LINK_ONLY:lz4::lz4>;\$<LINK_ONLY:mp4v2::mp4v2>;\$<LINK_ONLY:protobuf::libprotobuf>;\$<LINK_ONLY:depthai::messages>;\$<LINK_ONLY:depthai::foxglove_websocket>;\$<LINK_ONLY:apriltag::apriltag>;\$<LINK_ONLY:CURL::libcurl_static>;\$<LINK_ONLY:cpr::cpr>;xtensor;\$<LINK_ONLY:Backward::Backward>"
)

depthaiTargets.cmake

depthaiTargets.cmake.txt

Expected behavior

It is expected that the targets declared in lib/cmake/depthai/depthaiTargets.cmake are actually present at link time of a consuming CMake project.

Screenshots

Not applicable.

Pipeline Graph

Not applicable.

Attach system log

64-bit RPiOS (Debian 12) on RPi 5

log_system_information_rpi5_rpios.json

Ubuntu Server 24.04 on RPi 5

log_system_information_rpi5_ubuntu.json

Additional context

The goal is to statically link depthai-core into another CMake project.

An apt-get install … of libraries, which would otherwise provide the targets, does the resolve the fact that depthai-core does not provide the targets which lib/cmake/depthai/depthaiTargets.cmake states to be present.

sudo apt-get update
sudo apt-get install libfmt-dev \
    libprotobuf-dev protobuf-compiler \
    libwebsocketpp-dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions