Skip to content
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

[Bug] aliases "zenohc::static" and "zenohhc::lib" not globally visible, with CMake 3.16 #111

Closed
kjrusscher opened this issue Dec 20, 2022 · 1 comment · Fixed by #115
Closed
Labels
bug Something isn't working

Comments

@kjrusscher
Copy link
Contributor

Describe the bug

Zenoh-cpp cannot be compiled because the cmake file zenohcConfig.cmake throws an error when using CMake 3.16. The reason is that "zenohc::static" and "zenohhc::lib" are not globally visible. In CMake 3.18+ this problem is solved, but not in CMake 3.16 which is the default option in Ubuntu 20.04.

Why is this zenoh-cpp compilation error a zenoh-c problem? Because the file that causes it (zenohcConfig.cmake) is generated when compiling zenoh-c.

More details can be found in eclipse-zenoh/zenoh-cpp#7

To reproduce

  1. Compile zenoh-c.
git clone https://github.com/eclipse-zenoh/zenoh-c.git && \
cd zenoh-c && mkdir -p build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/home/username/local && \
cmake --build . --target install
  1. Use cmake on zenoh-cpp
git clone https://github.com/eclipse-zenoh/zenoh-cpp.git && \
cd zenoh-cpp && mkdir -p build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/home/username/local
  1. Error:
  add_library cannot create ALIAS target "zenohc::static" because target
  "__zenohc_static" is imported but not globally visible.
Call Stack (most recent call first):
  CMakeLists.txt:42 (find_package)


CMake Error at /home/username/local/lib/cmake/zenohc/zenohcConfig.cmake:46 (add_library):
  add_library cannot create ALIAS target "zenohc::lib" because target
  "__zenohc_lib" is imported but not globally visible.
Call Stack (most recent call first):
  CMakeLists.txt:42 (find_package)

System info

  • Ubuntu 20.04
  • CMake 3.16.3
@kjrusscher kjrusscher added the bug Something isn't working label Dec 20, 2022
@kjrusscher
Copy link
Contributor Author

It's a problem with CMake 3.16. It can be solved by editing PackageConfig.cmake.in.

Lines 17 and 21 have the functions add_library(__zenohc_static STATIC IMPORTED) and add_library(__zenohc_lib STATIC IMPORTED). Adding GLOBAL to those functions solves the problem.

I will try to change the generation of those files in zenoh-c and upload them as a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant