Skip to content

zxing.pc.in: fix when CMAKE_INSTALL_<dir> is absolute#468

Merged
axxel merged 1 commit intozxing-cpp:masterfrom
bjornfor:fix-pc-file-cmake-variables
Jan 1, 2023
Merged

zxing.pc.in: fix when CMAKE_INSTALL_<dir> is absolute#468
axxel merged 1 commit intozxing-cpp:masterfrom
bjornfor:fix-pc-file-cmake-variables

Conversation

@bjornfor
Copy link
Copy Markdown
Contributor

@bjornfor bjornfor commented Jan 1, 2023

pkg-config files are not designed to be relocatable, so the only thing
we need to do is using CMAKE_INSTALL_FULL_<dir> to avoid broken path
concatenation when CMAKE_INSTALL_<dir> is already absolute (like in
Nixpkgs).

https://cmake.org/cmake/help/v3.25/module/GNUInstallDirs.html

Fixes #335

@bjornfor bjornfor marked this pull request as ready for review January 1, 2023 17:43
pkg-config files are not designed to be relocatable, so the only thing
we need to do is using CMAKE_INSTALL_FULL_<dir> to avoid broken path
concatenation when CMAKE_INSTALL_<dir> is already absolute (like in
Nixpkgs).

https://cmake.org/cmake/help/v3.25/module/GNUInstallDirs.html

Fixes #335
@bjornfor bjornfor changed the title xzing.pc.in: fix when CMAKE_INSTALL_<dir> is absolute zxing.pc.in: fix when CMAKE_INSTALL_<dir> is absolute Jan 1, 2023
@bjornfor
Copy link
Copy Markdown
Contributor Author

bjornfor commented Jan 1, 2023

Amended to fix s/xzing/zxing/ typo.

@axxel axxel merged commit 549551c into zxing-cpp:master Jan 1, 2023
@bjornfor
Copy link
Copy Markdown
Contributor Author

bjornfor commented Jan 1, 2023

Thanks!

@bjornfor bjornfor deleted the fix-pc-file-cmake-variables branch January 1, 2023 21:44
@axxel
Copy link
Copy Markdown
Collaborator

axxel commented Jan 2, 2023

Just noticed, looking at a test-run of make install, that my zxing.pc does not look like I expected:

prefix=/home/axel/contrib/zxing-cpp.install
exec_prefix=${prefix}
libdir=
includedir=

Ideas?

@bjornfor
Copy link
Copy Markdown
Contributor Author

bjornfor commented Jan 2, 2023

Oh, sorry, I should have tested before submitting. I think we need to update the cmake code that generates the final .pc file too. Will submit fix later today.

@bjornfor
Copy link
Copy Markdown
Contributor Author

bjornfor commented Jan 2, 2023

@axxel: Fix here: #469

(This time I did a build to verify the change.)

axxel added a commit that referenced this pull request Jan 2, 2023
 * cleanup zxing.pc
 * define the project version on the library level, not the top level,
   makes sure the ZXVersion.h is generated properly also for all the
   wrappers.
 * also fixes issue seemingly introduced with #468
@axxel
Copy link
Copy Markdown
Collaborator

axxel commented Jan 2, 2023

Thanks. Your fix works but I don't understand why it is required because a) the formerly used non-FULL versions should be defined iff the FULL versions are and b) the fix that has been used and working on the NixOS side was exactly what your original PR did.

Anyway, I reorganized the .pc file and CMakeConfig generation and this takes also care of the missing GNUInstallDirs include. That said, I'd appreciate if you could test the code especially with respect to those changes. I don't have a setup that properly tests the validity of the generated .pc file.

@bjornfor
Copy link
Copy Markdown
Contributor Author

bjornfor commented Jan 2, 2023

Thanks. Your fix works but I don't understand why it is required because a) the formerly used non-FULL versions should be defined iff the FULL versions are and b) the fix that has been used and working on the NixOS side was exactly what your original PR did.

I think cmake itself defines CMAKE_INSTALL_<dir>, but require GNUInstallDirs for CMAKE_INSTALL_FULL_<dir>. (I don't know about anything this working on NixOS with -DCMAKE_INSTALL_<dir>=/absolute without using GNUInstallDirs.)

Anyway, I reorganized the .pc file and CMakeConfig generation and this takes also care of the missing GNUInstallDirs include. That said, I'd appreciate if you could test the code especially with respect to those changes. I don't have a setup that properly tests the validity of the generated .pc file.

libdir= and includedir= look fine, and are the only variables used by the .pc file itself. I don't know if anyone is using prefix= (which is now removed).

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.

zxing.pc is broken when CMAKE_INSTALL_{INCLUDE,LIB}DIR is absolute

2 participants