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

yaml-cpp error with CMake < 3.18 #1322

Closed
DownerCase opened this issue Jan 20, 2024 · 1 comment · Fixed by #1323
Closed

yaml-cpp error with CMake < 3.18 #1322

DownerCase opened this issue Jan 20, 2024 · 1 comment · Fixed by #1323

Comments

@DownerCase
Copy link
Contributor

Problem Description

#1250 Introduced an alias to yaml-cpp if not already present. This works great on CMake versions 3.18 or greater.
With older versions CMake fails with the message:

CMake Error at app/meas_cutter/CMakeLists.txt:27 (add_library):
  add_library cannot create ALIAS target "yaml-cpp::yaml-cpp" because target
  "yaml-cpp" is imported but not globally visible.

The ability to create a scoped ALIAS for non-global imported libraries was introduced in version 3.18.
add_library(ALIAS) Documentation

This affects Ubuntu 20 and any other environment running CMake less than 3.18

This issue isn't caught by CI because it uses the latest CMake version.

To resolve this I could find two options:

  1. Increase the minimum required version to at least 3.18
  • Requires Ubuntu 20 to acquire new CMake versions, not that its difficult and the Ubuntu 18 instructions already have that procedure.
  1. Take inspiration from this GitLab issue and do something like:
if (NOT TARGET yaml-cpp::yaml-cpp AND TARGET yaml-cpp)
    add_library(yaml-cpp::yaml-cpp INTERFACE IMPORTED)
    target_link_libraries(yaml-cpp::yaml-cpp INTERFACE yaml-cpp)
endif()

I was able to test option 2; it built and ldd showed it linking to libyaml-cpp.so correctly. 😄

I can make a PR with your preferred choice if you'd like.

How to reproduce

  1. Try to configure master using CMake <3.18 with meas_cutter included in the build (BUILD_APPS and HAS_HDF5)
  2. Observe the failure.

How did you get eCAL?

Custom Build / Built from source

Environment

  • eCAL master (5.13)
  • Primarily Ubuntu 20; but could affect any.
  • CMake < 3.18

eCAL System Information

No response

@FlorianReimold
Copy link
Member

Hi @DownerCase,

Thanks for testing this! While I don't really mind the incompatibility, I would still prefer option 2, especially for the support branches.

If you would make a PR, that would be amazing 😊

Kind Regards
Florian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants