-
Notifications
You must be signed in to change notification settings - Fork 455
Cleanup pkg-config #1326
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
Cleanup pkg-config #1326
Conversation
This reverts commit c4a4008.
build/cmake/ResSearch.cmake
Outdated
@@ -1,6 +1,9 @@ | |||
include(CheckSymbolExists) | |||
include(CMakePushCheckState) | |||
|
|||
# Required so that some libresolv symbols will be visible: | |||
set(CMAKE_C_EXTENSIONS ON) |
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 seemingly-unrelated change is due to changing cmake_minimum_required
in libmongoc, which changed the way that the C_STANDARD
property is propagated through try_compile
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.
Can this be scoped or moved into a target property? I have reservations about enabling C extensions for potentially all targets that follow include(ResSearch)
. If this must be set unconditionally, suggest moving up into the root CMakeLists.txt file alongside other project-wide variables.
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 also did not like this change, and it isn't obvious from the documentation that this variable effects try_compile
. I believe the reason we get away with it is that we enable bits and pieces by using platform-specific feature toggle macros. I will narrow it down and find what macros actually need to be defined to enable libresolv to compile properly.
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.
Looks to actually be _BSD_SOURCE
, which we already set, and I'm dropping it on the floor by using cmake_push_check_state(RESET)
. Oops.
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.
LGTM, modulo the one typo I found.
build/cmake/GeneratePkgConfig.cmake
Outdated
|
||
DESTINATION <dir> | ||
- If provided, specify the *directory* (relative to the install-prefix) | ||
in which the generated file will be installed. If unspecfied, the default |
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.
in which the generated file will be installed. If unspecfied, the default | |
in which the generated file will be installed. If unspecified, the default |
build/cmake/ResSearch.cmake
Outdated
@@ -1,6 +1,9 @@ | |||
include(CheckSymbolExists) | |||
include(CMakePushCheckState) | |||
|
|||
# Required so that some libresolv symbols will be visible: | |||
set(CMAKE_C_EXTENSIONS ON) |
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.
Can this be scoped or moved into a target property? I have reservations about enabling C extensions for potentially all targets that follow include(ResSearch)
. If this must be set unconditionally, suggest moving up into the root CMakeLists.txt file alongside other project-wide variables.
@@ -1,4 +1,4 @@ | |||
cmake_minimum_required (VERSION 3.1) | |||
cmake_minimum_required (VERSION 3.15) |
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 is a significant change. I suggest at least creating a CXX C ticket to track/document this new requirement.
Side question: is there a compelling reason we should continue to support a per-library CMake Project configuration instead of using only the root CMake project for all targets defined in the CXX Driver C Driver? I don't think we intend to support add_subdirectory()
of a CXX Driver C Driver library (i.e. bsoncxx libbson) without going through the root directory, do we?
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.
We're already requiring this at the top level, so this line could likely actually just be removed. It's actually probably bad that we had 3.1
there, since it would rewind a bunch of CMake policies and probably had some unintentional effects. (Such as the problem in ResSearch).
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 don't think we intend to support
add_subdirectory()
of a CXX Driver library (i.e. bsoncxx) without going through the root directory, do we?
AFAIK there is no expectation to support add_subdirectory()
without going through the root directory.
I expect C++ driver can be included with add_subdirectory
of the root CMakeLists.txt, and CXX-2104 was filed to document.
This PR is for the C driver (not C++).
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.
Had my repos mixed up. Sorry for the confusion.
All named parameters accept generator expressions. | ||
|
||
]==] | ||
function(mongo_generate_pkg_config target) |
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.
It baffles me that CMake doesn't provide any utilities to support smart target-based pkg-config file generation. 😞
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.
GeneratePkgConfig.cmake seems generally useful.
@@ -807,6 +807,7 @@ set_target_properties (mongoc_shared PROPERTIES | |||
SOVERSION 0 | |||
pkg_config_REQUIRES "libbson-1.0" | |||
) | |||
mongo_generate_pkg_config(mongoc_shared INSTALL RENAME libmongoc-${MONGOC_API_VERSION}.pc) |
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.
Consider using FILENAME
for consistency with other mongo_generate_pkg_config
calls.
Is there a use case for setting different values for RENAME
and FILENAME
? Consider removing RENAME
.
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.
RENAME
comes from install(FILES ...)
. The split in this case helps with multi-config generators. We want to allow multi-conf generation to work in the build, but we only need to install one version at a time.
On my yak-shaving journey to remove the source-dist, I ended up needing to rewrite the generation of pkg-config files (again) (long story). Fortunately, this is much cleaner and more robust than my prior silliness in #1301. The following now Just Works™:
link-with
scripts, since my local system would enable sanitizers, but the generated example executable did not have the appropriate link flags when it consumed libmongoc/libbson via pkg-config. This will now work out-of-the-box.prefix
value in the installed.pc
values is now bound at install-time, and not at configure-time. This allows usingcmake --install --prefix=<some-dir>
to do an install into an arbitrary<some-dir>
which may not be theCMAKE_INSTALL_PREFIX
. This is a somewhat-obscure feature, but I've found it useful and it was easy enough to make it work.cmake --install --config=<config>
to install the named configuration, and the appropriate.pc
file will be installed. (But multi-config.pc
install requires each configuration to receive a different.pc
filename, which is really weird for pkg-config and is not used here.)