0

Summary

When I click (Right click -> "Go To Definition F12"), I would like it to show me the source of external libraries compiled with cmake.

Details/What I've tried

I was under the impression that in (Properties -> VC++ Directories -> Source Directories) I could just add the path and Intellisense would pick it up, but that doesn't seem to do it. I used to copy the source code into the project directory (but not compile it). That worked but that got annoying because "Find and replace in project" would really mess things up. I could theoretically reference the cmake generated visual studio project files, but since everything is already automatically compiled on the command line and linked properly in my project, I'm not sure if that's the best option because it involves upgrading all the visual studio project files and potentially cluttering the project and maybe making it less portable.

Maybe relevant details:

  • Only the dependencies are compiled with cmake
  • Visual studio version is 2022
  • I use the "show all files" method in answer to this question to compile my my files
  • I really just want Intellisense data for the external library source outside of my project
  • External library files are not in $(ProjectDir)

Anyway, any help appreciated and feel free to lend advice on how you'd setup the project.

user2940623
  • 369
  • 3
  • 14
  • 1
    How do you load the dll? LoadLibrary() or as Dependencies? – Minxin Yu - MSFT Jun 01 '23 at 02:19
  • Exports from static library usually. I do have the source even though I do reference the dependencies as a dll. – user2940623 Jun 01 '23 at 02:27
  • Mmm no. It's just standard stuff. Link with a static library that will load the DLL on it's own kind of thing. Is how I link necessary for Intellisense? Just to say I don't really know how Intellisense works. Visual studio is a bit a mystery to me. – user2940623 Jun 01 '23 at 02:44
  • 1
    The header files of the static library should be `#include`. And intellisense will work. Can you describe the problem you encountered, or provide a screenshot of the problem. – Minxin Yu - MSFT Jun 01 '23 at 03:19
  • The headers are included, and intellisense will find the headers. They just don't find the source. – user2940623 Jun 01 '23 at 03:25
  • May I know if you have got any chance to check my answer? – Minxin Yu - MSFT Jun 09 '23 at 07:02

1 Answers1

1

It is by design. When the static library is compiled, the definition will be stored in lib file. And cpp files will no longer be used. You can drag the cpp files into Visual Studio instead of copying. It is able to find the source code.

Minxin Yu - MSFT
  • 2,234
  • 1
  • 3
  • 14