xxHash icon indicating copy to clipboard operation
xxHash copied to clipboard

Fix double prefix when building with cmake

Open ilya-fedin opened this issue 2 years ago • 2 comments

ilya-fedin avatar Jun 15 '22 12:06 ilya-fedin

@Cyan4973 ping

ilya-fedin avatar Aug 13 '22 07:08 ilya-fedin

@ilya-fedin, I'm sorry about these annoying errors! #736 will fix this issue.

t-mat avatar Sep 02 '22 15:09 t-mat

I'm trying to understand what was the objective of this PR.

The title mentions "Fix double prefix when building with cmake", which implies there's an issue when building with cmake. It's probably not a trivial scenario, since I could not detect any issue from basic cmake tests.

If that's the case, I would expect it should be possible to create a test case that reproduces this issue. Such test case could then be integrated into CI.

Looking at the PR's content, it appears focused on pkg-config generation. More specifically includedir and libdir are now set entirely from the build system, either make or cmake, instead of being derived from prefix within the pkgconfig file. The new design seems superficially similar to the original one, but I presume it differs in subtle ways, in order to fix some edge cases that were not properly covered. And since the new design is also a bit more complex, which is a cost to maintenance, I would like to understand precisely what it does better.

Note : I see that one test was failing, but my understanding is that the problem was on the test side, not the PR. We can ignore it.

Cyan4973 avatar Jun 24 '23 22:06 Cyan4973

Try to build xxHash with the following cmake arguments:

cmake -Bbuild -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_INCLUDEDIR=/usr/include -DCMAKE_INSTALL_LIBDIR=/usr/lib

This is valid for cmake but xxHash's build scripts generate pkg-config file in a way it gets /usr/usr/include, /usr/usr/lib

ilya-fedin avatar Jun 24 '23 22:06 ilya-fedin

OK ! Following the proposed test, I get the following content in libxxhash.pc :

prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}//usr/include
libdir=${exec_prefix}//usr/lib

which is obviously incorrect, and will lead to duplicated prefix /usr.

In contrast, after your patch, the content of libxxhash.pc becomes :

prefix=/usr
exec_prefix=${prefix}
includedir=/usr/include
libdir=/usr/lib

It's probably worth making a test from this example.

Cyan4973 avatar Jun 25 '23 00:06 Cyan4973

Sorry, but I don't have that much interest to create a test. If this is required to get the PR merged, I'd just close it and let someone else to do the work.

ilya-fedin avatar Jun 25 '23 01:06 ilya-fedin

Don't worry, I'm taking care of it (#845).

Cyan4973 avatar Jun 25 '23 04:06 Cyan4973