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

[question] How to support CMake "Interface" libraries and per-library cflags #6329

Closed
1 task done
nolange opened this issue Jan 9, 2020 · 2 comments
Closed
1 task done

Comments

@nolange
Copy link

nolange commented Jan 9, 2020

I have a package which generates a set of libraries and a set of interface targets, which don't have a real library behind them. See for example this target, whic just adss compiler and liner switches

# Create imported target Xenomai::posix
add_library(Xenomai::posix INTERFACE IMPORTED)

set_target_properties(Xenomai::posix PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "__COBALT_WRAP__"
  INTERFACE_LINK_LIBRARIES "-Wl,@${_IMPORT_PREFIX}/${_xenomai_libdir}/cobalt.wrappers;Xenomai::cobalt"
)

I dont believe conan can currently create them?
Also those libraries have separate C/LD FLAGS, which again conan is not able to provide.

Note that the package would provide a full config for CMake, so all that would be needed to use those would be adding "usr/lib/cmake/xenomai" to the find_package path. (Also relevant: #4967)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
# not quite happy with conan not creating these...
set(Xenomai_DIR "${CONAN_XENOMAI3_ROOT}/usr/lib/cmake/xenomai")

find_package(Xenomai 3.0 REQUIRED)
@jgsogo jgsogo self-assigned this Jan 10, 2020
@jgsogo
Copy link
Contributor

jgsogo commented Jan 10, 2020

Hi! Your question has different approaches:

Talking about builtin generators that create CMake targets (cmake, cmake_multi, cmake_find_package and cmake_find_package_multi): Conan creates one target per library defined in cpp_info.libs (and one more target to group them all), all the information defined in the cpp_info object is applied to each one and every target. So that is something not doable in a single package (we would need the components feature to allow something like that: #5408)

Creating your own generator: you can access the information in the cpp_info object and interpret it according to your needs. I highly discourage this approach as your package won't work with other generators and it won't be reusable by the community.

Package your own FindXenomai.cmake (or the config equivalent) and consumers will use it. At this moment we have good reasons to forbid .cmake files in conan-center-index and use the Conan generated ones, but for your own library, if needed, this is likely the way to go right now.

@memsharded
Copy link
Member

This ticket was using the old generators (legacy in 1.X, removed in 2.0), that have been superseded some time ago by new ones. Closing as outdated, please check the new ones and don't hesitate to open new tickets as necessary for any further question.

@memsharded memsharded closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants