-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-4013: C library: provide a libzookeeper.pc for pkg-config #1547
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
base: master
Are you sure you want to change the base?
Conversation
Previously, did this:
; cmake .
; make
; make install
ended up doing nothing, because CMakeLists.txt didn't include
INSTALL() directives. With this commit applied, the last
command outputs:
; make install
[ 18%] Built target hashtable
[ 75%] Built target zookeeper
[ 87%] Built target load_gen
[100%] Built target cli
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/zookeeper/zookeeper.h
-- Installing: /usr/local/include/zookeeper/proto.h
-- Installing: /usr/local/include/zookeeper/config.h
-- Installing: /usr/local/include/zookeeper/zookeeper_version.h
-- Installing: /usr/local/include/zookeeper/winconfig.h
-- Installing: /usr/local/include/zookeeper/zookeeper_log.h
-- Installing: /usr/local/include/zookeeper/recordio.h
-- Installing: /usr/local/lib/libzookeeper.a
Allows more easily integrating with other toolchains:
; pkg-config --cflags libzookeeper
-I/usr/local/include/
; pkg-config --libs libzookeeper
-L/usr/local/lib -lzookeeper
; pkg-config --libs --static libzookeeper
-L/usr/local/lib -lzookeeper /usr/local/lib/libzookeeper.a
8c7d506 to
8ef4d69
Compare
ztzg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| if(CYRUS_SASL_FOUND) | ||
| list(APPEND zookeeper_sources src/zk_sasl.c) | ||
| set(LIBS ${LIBS} -lsasl2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form creates a CMake "list," which ends up as a semi-separated string in the libzookeeper.pc. So you could either continue using a list (in which case I'd suggest list(APPEND LIBS ...)), or format a string by quoting as in set(LIBS "${LIBS} -lsasl2"). Yeah…
But in this case I'd suggest not adding those to pkg-config's Libs: at all (as you'd then also have to figure out the proper -L flags, etc.) but rather as Requires.private: libsasl2 (and, if OpenSSL is enabled, Requires.private: [...] libssl).
| INCLUDE(FindPkgConfig QUIET) | ||
| if(PKG_CONFIG_FOUND) | ||
| # generate .pc and install | ||
| CONFIGURE_FILE("libzookeeper.pc.in" "libzookeeper.pc" @ONLY) | ||
| INSTALL(FILES libzookeeper.pc | ||
| DESTINATION lib/pkgconfig) | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop the INCLUDE and subsequent PKG_CONFIG_FOUND conditional, as generating that small ASCII file does not actually require pkg-config at compilation time. But you prefer to keep it, I'd still suggest switching to find_package(PkgConfig QUIET).
| Description: Zookeeper C client library | ||
| Version: @CMAKE_PROJECT_VERSION@ | ||
| Libs: -L${libdir} -lzookeeper | ||
| Libs.private: @LIBS@ ${libdir}/libzookeeper@CMAKE_STATIC_LIBRARY_SUFFIX@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is libzookeeper.a in Libs.private? It seems -lzookeeper in Libs: should be enough.
With the commit merged, after
make install:NOTE: This also includes #1546 since there's no reason to do this without first actually installing the libraries & headers >.> So that should be resolved first!