Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Optiligence
Copy link

@Optiligence Optiligence commented Jun 6, 2017

So i tried to get my CMake wishes into the previous PRs, some of it landed, this is the rest.

Since the changed CMake config is pretty important for downstream use, i hope this can be included before the initial CMake release.

ad81778 is my take on one of CMake’s weak points, autotools allowed to do this before.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@Optiligence
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

CMakeLists.txt Outdated
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This is something other packages may have already started relying on, and I really see no advantage of making it uppercase (and therefore inconsistent with -lsnappy).

Even worse, if you change this, then packages that already target_link_libraries(snappy) will silently switch from linking the target to implicit -lsnappy.

Copy link
Author

@Optiligence Optiligence Jun 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optiligence@fb66b50#diff-af3b638bc2a3e6c650974192a53c7291L96
The output name stays the same.
CMake target names are usually upper cased.

tamird added a commit to cockroachdb/snappy that referenced this pull request Jul 6, 2017
This will be more robustly supported upstream when
google#38 is merged.
@ilovezfs
Copy link

@pwnall we just had a user report the lack of a static library: Homebrew/homebrew-core#15722

change CMake code to contemporary use of lower case
and consistency with SnappyConfig.cmake.in
also provide the same INSTALL_DESTINATION to configure_package_config_file
but explicitly specify the output name to be lower case.
the exported targets were already generated but unused

CMake exported targets exist for a very long time now
and essentially replace a large amount of manual variables
(include dir, library dir …)

the version also wasn’t set, because corresponding variables
got lost between PRs and c813168

a downstream project only needs to use the following
– if the install prefix of snappy is in its search path –
to add include directories and link the library

find_package(Snappy)
target_link_libraries(DownstreamTarget PUBLIC Snappy::Snappy) # yes, this also adds includes
…p of each other

set BUILD_SHARED_LIBS=FALSE to build the static version
shared is the default (as is BUILD_SHARED_LIBS=TRUE)
@Optiligence
Copy link
Author

rebased again

${Snappy_BINARY_DIR}/snappy-stubs-public.h
DESTINATION include)

if (BUILD_SHARED_LIBS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be nicer to have both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS, so you can build both a static and a shared library without reconfiguring in between?

Copy link
Author

@Optiligence Optiligence Jul 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no BUILD_STATIC_LIBS, BUILD_SHARED_LIBS is a CMake variable.
You would have to add 2 libraries and create targets with different names for each
combined with custom logic which enables or disables it.
downstream projects can’t use both at the same time anyway
The way it is now downstream gets shared snappy by default and would get static snappy when BUILD_SHARED_LIBS is set (which i consider the build-all-my-stuff-statically-please flag) which has the benefit that downstream doesn’t have to explicitly state anything in their CMake file, it’s only a build option.
One could also add explicit aliases on top of that (in the future?).
Reconfiguring in between has no downside anyway, it’s just a stylistic issue.
I’m quite happy with the way it is now, I also don’t know of any CMake projects which handle building static and shared flavors nicely to compare it with.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most CMake projects end up adding a _static suffix to the library name. Honestly this is actually pretty nice as one can clearly specify they want static linking on Unix by simply using this other library name.

@pwnall
Copy link
Member

pwnall commented Jul 20, 2017

Generic advice: If you want your PR to be helpful, please don't bundle a coding style change with an actual change.

In general, style choices tend to be intentional, and are (rightfully) optimized for the project maintainers, as they'll have to stare at the code for extended periods of time. In this case, I agree with the style change, as it matches the style in the CMake documentation, but the bundling still makes the diff useless.

Edit: I plan to look into the shared library issue today. The style change requires other people to agree, so no timeline there.

@Optiligence
Copy link
Author

When I initially brought this up here I maintained 2 versions, one with the capitalization changed and one without.
Since this got annoying pretty quick (after a few rebases without anybody responding) I concentrated on the version I was more comfortable with.
Imo it’s also not really useful to look at the complete diff anyway, the individual commits are easier to reason about (especially together with the commit message).

Thanks for looking into it.

@pwnall
Copy link
Member

pwnall commented Jul 31, 2017

@Optiligence The project's CMake configuration has been revamped. Sorry to ask for more work from you, but can you please check which parts of this PR still apply and rebase?

Also, if individual commits are easier to reason about, that's a pretty good sign that the commits should be in separate PRs.

@ilovezfs
Copy link

@mgorny Please try to be nice.

@Optiligence
Copy link
Author

I will work on it when i find the time.

@google google deleted a comment from mgorny Jul 31, 2017
@Optiligence
Copy link
Author

@pwnall You want ALLCAPS now or no?

@pwnall
Copy link
Member

pwnall commented Jul 31, 2017

@Optiligence no more CAPS 😄 I hope that'll make diff management easier for you.

@pwnall
Copy link
Member

pwnall commented Jul 31, 2017

@Optiligence Also, please make sure to rebase against master, not the latest release.

@Optiligence
Copy link
Author

Oh, nice, I didn’t have a look at the latest commit yet.

@Optiligence
Copy link
Author

Those 3 commits seem to be implemented: 66bd851 e23726b 26adadf
I will create a new PR (#54) for the rest because it’s not possible to rebase reasonably anymore.

On another note:
Reading and managing multiple interdependent PRs is not easier but more difficult than reading individual commits in 1 PR. (in other words: if individual commits are dependent on each other, that’s a pretty good sign that they should belong to 1 PR)
be6dc3d is also pretty interesting regarding the comment about unreadable merge commits (which is part of the nature of merge commits but not standalone commits). ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants