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

Lowering required CMake version for Ubuntu 20.04? #7

Closed
kjrusscher opened this issue Dec 19, 2022 · 9 comments · Fixed by eclipse-zenoh/zenoh-c#115
Closed

Lowering required CMake version for Ubuntu 20.04? #7

kjrusscher opened this issue Dec 19, 2022 · 9 comments · Fixed by eclipse-zenoh/zenoh-c#115

Comments

@kjrusscher
Copy link

The required cmake version for this repo is set to 3.21.

The package manager in Ubuntu 20.04LTS has cmake version 3.16. The required cmake version for Zenoh-C is version 3.10.

My question is; is 3.21 a deliberate choice? If not, could it be set to 3.16 so we don't have to recompile cmake on Ubuntu 20.04?

@Mallets
Copy link
Member

Mallets commented Dec 19, 2022

Fixed by #9. CMake version is now set to 3.16.

@Mallets Mallets closed this as completed Dec 19, 2022
@kjrusscher
Copy link
Author

I've tested this and it does not work. The error that I get is: add_library cannot create ALIAS target "zenohc::lib" because target "__zenohc_lib" is imported but not globally visible.. This is a CMake error. The problem is caused by lines 42 and 46 in /usr/local/lib/cmake/zenohc/zenohcConfig.cmake, so a file that is generated by installing zenoh-c. Here is explained how the problem can be solved, but that has to be done in how zenoh-c generates files.

My suggestion is to revert the change and go back to CMake 3.21 (for now) since that works.

@Mallets Mallets reopened this Dec 20, 2022
@milyin
Copy link
Contributor

milyin commented Dec 20, 2022

Yes, I've also encountered the same problem yesterday after the version rollback. The fix was to use absolute path in CMAKE_INSTALL_PREFIX - seems that old version of cmake treats relative path as relative to CMakeLists.txt location and newer version treats is as relative to current build directory.
So for now I think the better way to fix it is to just update readme, removing the recomendation to use relative path

@milyin
Copy link
Contributor

milyin commented Dec 20, 2022

Hi Milyin. Do you mean to use -DCMAKE_INSTALL_PREFIX=/usr/local? I did use that and it resulted in the error above.

That's strange. I used /home/username/local (to avoid working on root) both for zenoh-c and zenoh-cpp and it worked. I'll check it again

@kjrusscher
Copy link
Author

I tried the following just now: (username is my own user name)

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 && \
cd ../.. && \
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 && \
cmake --build . --target install 

This results in the error:

CMake Error at /home/username/local/lib/cmake/zenohc/zenohcConfig.cmake:42 (add_library):
  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)

I'm using Ubuntu 20.04 with CMake 3.16.3

@milyin
Copy link
Contributor

milyin commented Dec 20, 2022

For me this sequence works well on mac (cmake 3.25.1), Ubuntu 22.04 (cmake 3.22.1), Ubuntu 20.04 (cmake 3.23.2).
Seems that the problem is in some bug in old cmake version. Maybe it's mentioned here https://discourse.cmake.org/t/alias-and-not-globally-visible-targets/6305

@kjrusscher
Copy link
Author

I think it's a problem with CMake 3.16. It can be solved by editing zenohcConfig.cmake that is generated when compiling zenoh-c.

Lines 41 and 45 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.

Mallets added a commit to eclipse-zenoh/zenoh-c that referenced this issue Dec 21, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@milyin milyin reopened this Sep 19, 2023
@milyin
Copy link
Contributor

milyin commented Sep 19, 2023

Real cmake 3.16 doesn't work with current cmake files, despite that 3.20 works ok with 3.16 mode.

@milyin
Copy link
Contributor

milyin commented Oct 24, 2023

Fixed in #75

@milyin milyin closed this as completed Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants