Description
Problem Description
Subject: Cross-compiled eCAL requires manual Protobuf target definition in CMake configuration
Issue Description
After cross-compiling and installing eCAL to a custom prefix (/opt/makeblock
), CMake fails to configure dependent projects with the following error:
CMake Error at CMakeLists.txt:14 (find_package):
Found package configuration file:
/opt/makeblock/lib/cmake/eCAL/eCALConfig.cmake
but it set eCAL_FOUND to FALSE so package "eCAL" is considered to be NOT FOUND.
Reason given by package:
The following imported targets are referenced, but are missing:
protobuf::libprotobuf
The error occurs because eCALConfig.cmake
expects the imported target protobuf::libprotobuf
, which is not automatically resolved in the cross-compilation environment.
Workaround
Manually defining Protobuf targets resolves the issue:
# Workaround: Explicitly define missing Protobuf targets
if(NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf SHARED IMPORTED)
set_target_properties(protobuf::libprotobuf PROPERTIES
IMPORTED_LOCATION "/opt/makeblock/lib/libprotobuf.so"
INTERFACE_INCLUDE_DIRECTORIES "/opt/makeblock/include"
)
endif()
if(NOT TARGET protobuf::libprotobuf-lite)
add_library(protobuf::libprotobuf-lite SHARED IMPORTED)
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
IMPORTED_LOCATION "/opt/makeblock/lib/libprotobuf-lite.so"
INTERFACE_INCLUDE_DIRECTORIES "/opt/makeblock/include"
)
endif()
find_package(eCAL REQUIRED) # Succeeds after manual target definitions
Questions
-
Expected Behavior?
Should cross-compiled eCAL automatically propagate Protobuf dependencies, or is manual target definition required?
If manual setup is expected, should this be documented? -
Missing Configuration?
Does the eCAL build system require additional flags (e.g.,-DProtobuf_DIR
) when cross-compiling to establish proper target dependencies? -
CMake Script Improvement
CouldeCALConfig.cmake
include fallback logic to handle cases whereprotobuf::libprotobuf
is not found in the CMake registry?
Additional Context
- Protobuf was cross-compiled and installed to the same prefix (
/opt/makeblock
). find_package(Protobuf)
works if explicitly called beforefind_package(eCAL)
, but eCAL’s config does not invoke this internally.- Native (non-cross) builds on x86_64 work without manual intervention.
How to reproduce
When cross-compiling eCAL for ARM64 on an Ubuntu x86_64 host...
How did you get eCAL?
Custom Build / Built from source
Environment
- OS: Ubuntu 22.04 (host) / ARM64 (target)]
- eCAL Version: v5.13.3
- Protobuf Version: v3.12.4
- CMake Version: 3.26.2
- Cross-compilation Toolchain: aarch64-linux-gcc-v12.3
eCAL System Information