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

[question] Can you install the pc files in a different directory other than the builddir? #9496

Closed
1 task done
Makogan opened this issue Aug 29, 2021 · 11 comments · Fixed by #9341
Closed
1 task done
Assignees
Milestone

Comments

@Makogan
Copy link
Contributor

Makogan commented Aug 29, 2021

When following the guides on conan as is, all .pc files will be created in the same directory where the main executable lives.
If a project has a large number of dependencies you end up with dozens of pc files and it becomes challenging for a human to quickly see what is on the directory.

This is important for debugging and for using tools such as renderdoc where one may want to look for a specific file using a UI.

Is it possible to instruct conan to separate pc files form the executable's builddir?

@memsharded
Copy link
Member

Hi @Makogan

Yes, with the new layout() functionality, and the self.folders.generators (https://docs.conan.io/en/latest/developing_packages/package_layout.html#self-folders), you can define where the generated files will be located.

Just beware that legacy build system integrations will not directly understand this layout and might need some manual adaption, only the new integrations in conan.tools will use the layout automatically: https://docs.conan.io/en/latest/reference/conanfile/tools.html

@Makogan
Copy link
Contributor Author

Makogan commented Aug 30, 2021

Hello,

Thank you for your reply, I am still a bit lost.

From the documentation is seems it should be enough to add the following to the conan.py file:

def layout(self):
        self.folders.build = "cmake-build-{}".format(str(self.settings.build_type).lower())
        self.folders.generators = os.path.join(self.folders.build, "generators")
        self.folders.imports = self.folders.build
        self.folders.source = "src"

And then run:

conan install . -if=my_install -s build_type=Debug

The docs say:

This will write the toolchains and generator files from the dependencies to the cmake-build-debug/generators

From that I would expect a cmake-build-debug to be generated either on the project root or under my_install and then inside of its generators subfolder, all the pc files. But what I see is all the pc files under my_install and no cmake-build-debug directory.

I am on conan 1.39 under linux and the docs say this feature is available from conan 1.37. Am I doing something wrong?

@memsharded
Copy link
Member

Hi @Makogan

The -if=myinstall is a legacy from the previous mode, that is not possible to remove it yet, it is used to generate the conaninfo.txt and conanbuildinfo.txt that are needed for some local commands. But the new layouts ignore that argument. The reason is that if the layout now depends on an unknown, non-modelled command line argument, it is very difficult to achieve the reproducibility and portability of the layout.

Can you please make sure you are using the PkgConfigDeps generator? This is the modern one that should be following the layout and put the .pc files in the generators folder.

@Makogan
Copy link
Contributor Author

Makogan commented Aug 30, 2021

@memsharded How can I check which generator I am using?

This is how I declared the generator:

generators = "pkg_config"

@memsharded
Copy link
Member

Yes, please use:

generators = "PkgConfigDeps"

you can get more info in this reference page: https://docs.conan.io/en/latest/reference/conanfile/tools.html

@Makogan
Copy link
Contributor Author

Makogan commented Aug 30, 2021

Now I get this error:

ERROR: Error in generator 'PkgConfigDeps': {'ref': expat/unknown@unknown/unknown, 'build': False, 'direct': True, 'test': False}

I also tried changing things to use:

 def generate(self):
        pc = PkgConfigDeps(self)
        pc.generate()

Instead, but I get the same error.

@memsharded
Copy link
Member

Just to make sure, which Conan version are you using?
Also, what kind of requirement is expat, a regular requires?

@Makogan
Copy link
Contributor Author

Makogan commented Aug 30, 2021

This is what I see in the terminal:
Conan version 1.39.0

expat is not explicitly required it might be a dependency of the explicit dependencies:

requires = [
        "libffi/3.4.2", # Not sure why but without this wayland causes a conflict.
        "wayland/1.19.0",
        "glfw/3.3.4",
        "shaderc/2019.0",
        "freetype/2.10.4",
        "harfbuzz/2.8.2",
        "vulkan-memory-allocator/2.3.0",
        "gtest/1.10.0",
        "benchmark/1.5.3",
        "tinygltf/2.5.0",
        "stb/20200203",
        "vulkan-headers/1.2.182",
        "vulkan-validationlayers/1.2.182",
    ]

@memsharded memsharded modified the milestones: 1.41, 1.40 Aug 31, 2021
@memsharded
Copy link
Member

memsharded commented Aug 31, 2021

Hi @Makogan

Sorry for the confusion. I have realized this is working in our develop branch, but is a bug that is still existing in Conan 1.39 and is being fixed in Conan 1.40 (to be released next Monday most likely).

This is the PR that fixed it: #9341

@memsharded memsharded mentioned this issue Aug 31, 2021
5 tasks
@memsharded
Copy link
Member

Verified that this works with the layout() above and the new PkgConfigDeps in 1.40, so this can be closed as solved, keep tuned to the release.

Please do not hesitate to report or ask any other question you might have. Thanks!

@Makogan
Copy link
Contributor Author

Makogan commented Aug 31, 2021

Thank you very much James, I will check the feature out when the next version comes out.

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