-
Notifications
You must be signed in to change notification settings - Fork 90
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
Feature Request: Support librdkafka from add_subdirectory #169
Comments
Alternatively, provide a bundled version of |
Not sure whether While, if you're interested, I'd suggest to have a try with I'm not quite expert for A demo project for |
This usually works. It is possible to depend on a target from subdirectory A while being in subdirectory B if the subdirectories are added in a valid order.
I could use |
Hi, @stertingen I like your idea but I'm not sure whether it could be achieved with a normal (with no "ugly hack") approach.
You might want the sequence of |
That's the only way the build currently works. And that will continue to work if done right (see below). Most CMake projects allow multiple kinds of 'being included' by other projects. Fully building and installing a sub-project before configuring another is not always useful, especially when cross-compiling.
I would expect the following behavior from this project's
If needed, an option can be added to 'B's CMakeLists.txt to force finding 'A' on it's install path. The point I'm trying to make is that I would like to get rid of the need to install 'A' before being able to use it. |
About |
if(NOT TARGET rdkafka)
# determine and LIBRDKAFKA_INCLUDE_DIR and LIBRDKAFKA_LIBRARY_DIR
endif() if(TARGET rdkafka)
# Link against target rdkafka
target_link_libraries(${PROJECT_NAME} rdkafka)
else()
# Link manually against installed rdkafka
target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE ${LIBRDKAFKA_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} INTERFACE ${LIBRDKAFKA_LIBRARY_DIR})
target_link_libraries(${PROJECT_NAME} INTERFACE rdkafka)
endif() However, rdkafka does export the target as If you want to cover all cases, both target |
Since
modern-cpp-kafka
only works with recent versions oflibrdkafka
, I see myself forced to not use the system-provided version oflibrdkafka
.I considered
vcpkg
, but it did not seem feasible to set upvcpkg
just for a single package, sincemodern-cpp-kafka
is not available onvcpkg
.So in my current setup, I have both
librdkafka
andmodern-cpp-kafka
next to each other in different subdirectories.I would expect the following CMake snippet to work:
Unfortunately, there are 2 issues:
librdkafka
makes headers available withoutlibrdkafka
prefix, so#include <rdkafka.h>
is needed instead of#include <librdkafka/rdkafka.h>
. Maybe this issue should be fixed inlibrdkafka
, but CMake support there is kind of unofficial.modern-cpp-kafka
requires environment variables to be set to find headers and libraries. I would propose to implement aFindRdKafka
CMake module and check for the existence of therdkafka
target.Are there best practices on how to set up
librdkafka
withmodern-cpp-kafka
with compatible versions?The text was updated successfully, but these errors were encountered: