Skip to content
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

[bug] prefix in pkg-config (.pc) file is emtpy when in editable mode #12477

Closed
joastoe opened this issue Nov 7, 2022 · 6 comments · Fixed by #12529
Closed

[bug] prefix in pkg-config (.pc) file is emtpy when in editable mode #12477

joastoe opened this issue Nov 7, 2022 · 6 comments · Fixed by #12529
Assignees
Milestone

Comments

@joastoe
Copy link

joastoe commented Nov 7, 2022

I just updated conan to version 1.53.0 and am surprised that my .pc files generated with PkgConfigDeps into build/generators contain an empty prefix. This only when in editable mode. I use the layout() feature.

With conan 1.44

prefix=/home/dev/git/libname
libdir1=${prefix}/build/src
includedir1=${prefix}/include
includedir2=${prefix}/build/include
includedir3=${prefix}/build/include/libname

With conan 1.53

prefix=
libdir1=${prefix}/build/generators/build/src
includedir1=${prefix}/../../include
includedir2=${prefix}/../include
includedir3=${prefix}/../include/libname

Is this a bug or did I miss to migrate some variable in the layout() section.
Thanks

@franramirez688
Copy link
Contributor

Hi @joastoe

I think this is the expected behavior. You can have a look at this issue #11435.
So, it'll always be "" when in editable mode.

@joastoe
Copy link
Author

joastoe commented Nov 7, 2022

Hi @franramirez688

I don't get it, if this is expected behavior how can I get It work otherwise then?
An empty prefix path will let cmake fail as the include dirs are all pointing to an in existent path. E.g.
/include instead of /home/dev/git/libname/include.

Seems to me as if the generation of the dependency's root path (=prefix) got lost somewhere on the road.

@joastoe
Copy link
Author

joastoe commented Nov 7, 2022

I investigated further.
The issue persists since conan version 1.46.0

package_folder is not defined anymore

ERROR: Traceback (most recent call last):
  File "/home/dev/.local/lib/python3.8/site-packages/conans/client/generators/__init__.py", line 177, in write_generators
    generator.generate()
  File "/home/dev/.local/lib/python3.8/site-packages/conan/tools/gnu/pkgconfigdeps/pkgconfigdeps.py", line 32, in generate
    generator_files = self.content
  File "/home/dev/.local/lib/python3.8/site-packages/conan/tools/gnu/pkgconfigdeps/pkgconfigdeps.py", line 17, in content
    for pc_name, pc_content in get_pc_files_and_content(self._conanfile, dep).items():
  File "/home/dev/.local/lib/python3.8/site-packages/conan/tools/gnu/pkgconfigdeps/pc_files_creator.py", line 117, in get_pc_files_and_content
    pc_files.update(_get_single_package_pc_file_and_content(conanfile, dep, pkg_info))
  File "/home/dev/.local/lib/python3.8/site-packages/conan/tools/gnu/pkgconfigdeps/pc_files_creator.py", line 99, in _get_single_package_pc_file_and_content
    pc_name, pc_content = get_pc_filename_and_content(conanfile, dep, package_info.name,
  File "/home/dev/.local/lib/python3.8/site-packages/conan/tools/gnu/pkgconfigdeps/pc_files_templates.py", line 94, in get_pc_filename_and_content
    prefix_path = package_folder.replace("\\", "/")
AttributeError: 'NoneType' object has no attribute 'replace'

I know that this AttributeError then was fixed by issue #11435 but my concern is why the package_folder variable isn't defined anymore.

@franramirez688
Copy link
Contributor

franramirez688 commented Nov 8, 2022

Hi @joastoe

Sorry for the delay. Yes, you're right that it's a bug.
I just reproduced it locally, getting this error message:

CMake Error in CMakeLists.txt:
  Imported target "PkgConfig::HELLO" includes non-existent path

    "/../../../../../../../../../../develop/conan/mytest/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

I don't know if it'll be as simple as putting internally "." by default. I have to figure out a couple of things more.
I'll try to make a pull request to solve this issue in the next Conan 1.55 release.
Thanks for reporting it! 😄

@franramirez688 franramirez688 added this to the 1.55 milestone Nov 8, 2022
@franramirez688 franramirez688 self-assigned this Nov 8, 2022
@joastoe
Copy link
Author

joastoe commented Nov 9, 2022

Hi @franramirez688
No problem, I'm happy to help.
Let me know if I can test anything related.

@franramirez688
Copy link
Contributor

franramirez688 commented Nov 17, 2022

Closed by #12529
This fix will be available in the next Conan 1.55 release.

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

Successfully merging a pull request may close this issue.

2 participants