-
Notifications
You must be signed in to change notification settings - Fork 455
Simplify Deprecated CMake Packages as Wrappers Around Current Packages #1384
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
Conversation
- The computation of BUILD_VERSION is now lifted above project(), which allows us to use that value in the project() call itself, giving us correct PROJECT_VERSION values throughout. - Define BUILD_VERSION using mongo_setting(), and use the calc_release_version.py to compute its default value.
- Remove a lot of variable capture that was relied upon when generating - The _LIBRARY/_LIBRARIES variables in the legacy packages now point to the imported target of their respective packages, which will handle all other "magic variable" definitions.
set (CPACK_PACKAGE_VERSION_MAJOR ${BSON_MAJOR_VERSION}) | ||
set (CPACK_PACKAGE_VERSION_MINOR ${BSON_MINOR_VERSION}) | ||
|
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.
These values are inferred from project()
, which now contains the correct version information.
(Not sure if we have many CPack users anyway, though)
set_target_properties(${TARGETS_TO_INSTALL} PROPERTIES | ||
pkg_config_NAME libbson | ||
pkg_config_DESCRIPTION "The libbson BSON serialization library." | ||
pkg_config_VERSION "${BSON_VERSION}" | ||
) |
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.
Inferred from project()
set (LIBBSON_LIBRARIES "") | ||
foreach (_lib ${BSON_LIBRARIES}) | ||
if (_lib MATCHES ".*/.*" OR _lib MATCHES "^-") | ||
set (LIBBSON_LIBRARIES "${LIBBSON_LIBRARIES} ${_lib}") | ||
else () | ||
set (LIBBSON_LIBRARIES "${LIBBSON_LIBRARIES} -l${_lib}") | ||
endif () | ||
endforeach () | ||
# System dependencies don't match the above regexs, but also don't want the -l | ||
foreach (_lib ${BSON_SYSTEM_LIBRARIES}) | ||
set (LIBBSON_LIBRARIES "${LIBBSON_LIBRARIES} ${_lib}") | ||
endforeach () | ||
|
||
include (CMakePackageConfigHelpers) | ||
set (INCLUDE_INSTALL_DIRS "${BSON_HEADER_INSTALL_DIR}") | ||
set (LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR}) |
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.
Only used by the old script generation during configure_file
, so these aren't needed otherwise.
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.
Nice! I'm all about simplifying and eliminating unnecessary code. Just a few typo fix recommendations, but aside from that LGTM.
Co-authored-by: Roberto C. Sánchez <[email protected]>
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, the simplification is appreciated.
set (MONGOC_VERSION_FULL @libmongoc_VERSION_FULL@) | ||
|
||
include(CMakeFindDependencyMacro) | ||
find_dependency (mongoc-1.0 "@libmongoc_VERSION_MAJOR@.@libmongoc_VERSION_MINOR@") |
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.
Is @libmongoc_VERSION_MAJOR@.@libmongoc_VERSION_MINOR@
needed? libbson-1.0-config.cmake.in does does not include the version in the call to find_dependency
.
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.
Good question. Presumably, if this file is installed then the equivalent new package will be installed, so this version may be redundant.
The old CMake config-file-packages were generated by mostly-identical scripts and processes, but are deprecated in favor of our newer config-file-packages. I think it is safe at this point to replace the content of the deprecated package scripts with scripts that import the new packages and expose them in a mostly-compatible* manner.
The legacy package generation significantly cluttered and complicated the CMakeLists for the respective projects, since a lot of work was done to populate variables that were inserted into the script templates, whereas now those usage requirements are propagated via targets alone.
The new deprecated scripts no longer define/use the
INCLUDE_DIRS
/DEFINES
/etc variables, and onlyXYZ_LIBRARIES
/XYZ_LIBRARY
remain, which just contain the name of the equivalent imported target from the new CMake config-file-packages.* "mostly compatible" because the primary case of linking to e.g.
${BSON_LIBRARIES}
will "just work" withtarget_link_libraries
, but users that depended on the specificfind_library
call and/or inspected other variables e.g.BSON_INCLUDE_DIRS
will find that those are now not available. I think it is reasonable to assume that very few users, if any, were relying on this exact case.(This PR contains commits that are already merged by #1382.)