-
Notifications
You must be signed in to change notification settings - Fork 311
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
Add modern cmake config targets to s2geometry #339
Conversation
I will have to do some reading about modern CMake. I just based this on an example about ten years ago. |
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.
Does this change anything for people using it without vcpkg?
If you're asking if it will break existing downstream consumers, then the answer is no. Downstream projects, regardless of how they're building, and whether or not they use the Strictly speaking it does add to the build artifacts generated and installed (regardless of whether you're building from vcpkg or not), because it will create a few files in find_package(s2 CONFIG REQUIRED)
target_link_library(my_project PUBLIC s2::s2) This is the standard mechanism for packaging modern libraries built with CMake for other projects that are also using CMake. Additionally the exported target This makes lives easier for downstream consumers, with the caveat that package builders need to do a little more work to generate the config, but as you can see from this PR it's a very small amount of work. For further reading I'd suggest this section of the CMake online documents, or a recent edition of this book. I do kind of wish CMake would offer a simpler mode for developers that provided a prescribed file layout that can be customized, but that makes writing a CMake file for a project like this one more trivial, the sort of "convention over configuration" approach Maven managed to do for Java, and which ultimately has become the norm for more modern languages like Rust, Go, Python, etc... maybe someday. |
Fix formatting to be consistent with existing formatting. Mostly, this is aligning after "(" if possible without a line wrap and moving ")" to be on a line with other content. [")" handling does not seem to be consistent with the CMake docs, but is consistent with the rest of the file.]
Thanks for the explanations, and sorry for the delay! |
The current vcpkg version of s2geometry has to patch the CMakeLists.txt and generate a Config.cmake.in file in order to create a modern CMake target file that can then be found by other packages via
find_package
.Because this is a vcpkg addition, they mandate that this be placed in the
unofficial
namespace, in order to prevent any potential conflict with an eventual upstream config that might be introduced. This PR introduces the upstream config so that it can be used by anyone who builds the package and so that the vcpkg version no longer requires any patching at all.The changes here are essentially duplicating what the vcpkg patch does, except that they drop the
unofficial
prefix to everything, since the config would now be coming from the primary source.