-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed to use find_package(zenohpico)
[Bug]
#278
Comments
@milyin @jean-roland checking wether this issue is still open? |
Yeah, this haven't been fixed yet. |
When reviewing fix for bug, it was found that zenop-pico package installation is not correct now, this is not only single typo in example. First, I'll describe the whole concept and how package installation works:
# path to library file
set_property(TARGET __zenohc_static PROPERTY IMPORTED_LOCATION "/home/milyin/FOO/install/lib/libzenohc.a")
# additional libraries to be linked when linking this library
target_link_libraries(__zenohc_static INTERFACE rt;pthread;m;dl)
# include directories for the library
target_include_directories(__zenohc_static INTERFACE "/home/milyin/FOO/install/include")
# say that shared library doesn't contain soname property: https://en.wikipedia.org/wiki/Soname
set_target_properties(__zenohc_shared PROPERTIES IMPORTED_NO_SONAME TRUE)
# define additional preprocessor settings
target_compile_definitions(__zenohc_shared INTERFACE ZENOHC_DYN_LIB)
find_package(zenohc)
add_executable(app)
add_dependencies(app zenohc::lib)
target_link_libraries(app PRIVATE zenohc::lib) For zenoh-pico there are several problems:
The main problem with zenoh-pico is that it don't use target-local properties (i.e. it uses global
In the second case it will be hard to keep PackageConfig and CmakeLists.txt in sync, as they will be significantly different. Compare with how it's made in zenoh-cpp, where these files are practically the same: |
Describe the bug
There are 3 proper ways to use zenoh-pico library in customer cmake project:
find_package(zenohpico)
add_subdirectory(../zenoh-pico)
FetchContent
from github repository, which is just a wrapper over theadd_subdirectory
commandThe
find_package
includes filelib/cmake/zenohpico/zenohpicoConfig.cmake
generated from https://github.com/eclipse-zenoh/zenoh-pico/blob/master/PackageConfig.cmake.inThe
add_subdirectory
includes project's CMakeLists.txt: https://github.com/eclipse-zenoh/zenoh-pico/blob/master/CMakeLists.txtThis approach works well for zenoh-c and zenoh-cpp. See for example testing of these featues in zenoh-c CI:
Install zenohc package:
https://github.com/eclipse-zenoh/zenoh-c/blob/master/.github/workflows/ci.yml#L43-L45
Test building examples using zenoh-c directory as subproject:
https://github.com/eclipse-zenoh/zenoh-c/blob/master/.github/workflows/ci.yml#L72-L74
Test building examples using installed zenohc package:
https://github.com/eclipse-zenoh/zenoh-c/blob/master/.github/workflows/ci.yml#L79-L81
The CMakeLists.txt in
examples
directory of zenoh-pico also allows to test both approaches. At this moment building withfind_package
doesnt work for zenoh-picoIt's necessary to fix it and add testing of both approaches to CI, like it's done in zenoh-c
To reproduce
Install zenohpico as a package locally
Build examples using zenoh-pico as package:
This fails due to misconfigured line
https://github.com/eclipse-zenoh/zenoh-pico/blob/master/examples/CMakeLists.txt#L7
(zenohc instead of zenohpico::static)
But even after fix this the more problem comes: include direcrories and preprocessor settings are not provided to dependent project correctly
System info
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: