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]How to enable jumping to the source files of dependencies in Visual Studio? #16839

Closed
followtheart opened this issue Aug 17, 2024 · 5 comments
Assignees

Comments

@followtheart
Copy link

followtheart commented Aug 17, 2024

What is your question? How to enable jumping to the source files of dependencies in Visual Studio?

For example in simple_cmake_project
with conanfile.txt:

[requires]
zlib/1.2.11

[generators]
CMakeDeps
CMakeToolchain

and I following tutorial:

conan install . -s build_type=Debug --build="zlib/*"
cmake . --preset conan-default

then I can step into zlib's source file when debugging.
But my confusion is how to jumping to 3rd lib like zlib's function definition(which in .cpp/.c) in VS's editor?
Any requirements in CMakeLists.txt or conanfile.py of lib/app?
Environment details

Operating System+version: Win10
IDE: Visual Studio 2017 or 2022
Conan version: 2.4.1
CMake :3.26.6

Thx.

Have you read the CONTRIBUTING guide?

  • [-] I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Aug 17, 2024
@memsharded
Copy link
Member

Hi @followtheart

Thanks for your question.

Short answer: this is not possible, this is not a Conan limitation per-se.

Long answer: Note the dependencies are packages. Most of the time, they source code will not even exist in your machine, as conan install had installed pre-compiled binary libraries downloaded from the server.

Even if the built is done in the current cache, building from source, the final package is that a "package", and the source code is mostly decoupled from the final binaries. This is not even a Conan thing, this is something that even build systems do not model. If doing a find_package() in CMake, the located package will be in binary form, and it will be a external binary dependency of the current project, but it won't be possible to navigate to the dependency source .c/.cpp code from the current project. Other build systems like MSBuild or the like will also take "libs" to link (-lmylibtolink) and "libpaths" to locate those libs, but not any input to the source code of the dependency.

Said that, Conan has some tools that might help:

  • conan cache path can give you the paths in the cache to different folders, including the folder containing source code.
  • You can use the -c tools.build:download_source=True configuration to force conan to download the sources of the dependencies, even if they are not necessary because using a pre-compiled binary
  • When working simultaneously on more than one package (typically your own, not third-party source code like zlib that wouldn't be modified), it is possible to use the editable mode (this is an advanced feature, see https://docs.conan.io/2/tutorial/developing_packages/editable_packages.html)

@followtheart
Copy link
Author

Thx for your explain.
I will try this. https://docs.conan.io/2/tutorial/developing_packages/editable_packages.html

@memsharded
Copy link
Member

A couple of clarifications:

  • The editables are intended mainly for first-party code, not for third-party dependencies like zlib.
  • Editable packages require some correct definition of layouts, folders, etc in the recipe. Most of the ConanCenter recipes are not prepared for editable mode and will not work properly in editable mode. This is by design, ConanCenter recipes do not need to support the "local flow" with editable mode.
  • Editable mode allows to have the first party code in its respective user project, but not to navigate to it from the other project of the consumer of the editable.

If there are no further questions, I think the issue can be closed, you can always create new tickets for further questions. thanks!

@followtheart
Copy link
Author

Exactly,editable mode is what I need(for some private packages)!
I got some information from here. #11067 (comment)
And ,the video https://www.youtube.com/watch?v=VzUJQw89U7o&t=2437s showed the effect I wanted

Issue closed.Thx again.

@memsharded
Copy link
Member

Thanks for the feedback!

You might also want to track this ticket for the future: #15992
It will report progress on the "workspace" feature, that is a higher level of automation over editable projects.

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

No branches or pull requests

2 participants