-
Notifications
You must be signed in to change notification settings - Fork 994
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 generate a compile_commands.json
with conan dependencies?
#15416
Comments
Thanks for your question. I don't know the details yet, usually users with the VSCode CMake integrations don't have much problems, if CMake is able to build and find the dependencies, it should usually also use the includePaths, etc for the editor without issues. Maybe it is because you are using only the How did you generate the |
class ScratchEngine(ConanFile):
name = "ScratchEngine"
version = "0.1.0"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
# Runtime requirements
self.requires("imgui/1.90")
def build_requirements(self):
# Build requirements
self.tool_requires("cmake/[>=3.23]")
self.tool_requires("ninja/1.11.1")
def generate(self):
# Copy the ImGUI bindings
copy(
self,
"*impl_dx12*",
os.path.join(self.dependencies["imgui"].package_folder, "res", "bindings"),
os.path.join(self.source_folder, "bindings"),
)
copy(
self,
"*impl_win32*",
os.path.join(self.dependencies["imgui"].package_folder, "res", "bindings"),
os.path.join(self.source_folder, "bindings"),
) Command Line:
|
Thanks for the feedback. Did you change the Just trying to explore the issue, I am just experimenting with vscode. Some suggestions:
Without adding the Don't you have installed the |
The default VSCode settings with So it's only the |
Thank you, that was my mistake.
|
That's kind of a bug in Conan actually. You would expect that Conan fills in At that point Conan had called the setup scripts to populate the environment block with everything relevant to the compiler. It is also missing all the environment variables exported by dependencies it potentially had active at that time. And you suffer from a limitation in That makes it currently really difficult to use Conan with Ninja and MSVC without having to let Conan do the initial CMake cache configuration. But that actually brings you to #15427 - there are more pitfalls on that route. If conan were to run the |
Hi @nonlinearthink - thank you for raising this question. We've been able to reproduce this: A few things.
This would cause Cmake to generate
I would advise against modifying the global setting for all workspace, and rather keep it local. With these set up we are able to get clangd to index dependencies from the Conan cache as expected, without issues. It is useful to inspect the In recent installations of VSCode - if you call
I think this is unrelated to the issue experienced by the issue reporter. However, please be advised that #15427 has already been resolved, and #15470 should achieve what you described. |
What is your question?
Environments
OS: Windows
Compiler: msvc
Build System: CMake
IDE: VSCode with Clangd extension
Question
I can run my program correctly from the command line, but VSCode doesn't recognize the includePath, and I need to generate the
compile_commands.json
file.clangd
use it to find the includePath.Because
MSBuild
can't useCMAKE_EXPORT_COMPILE_COMMANDS
to generate acompile_commands.json
file, so I'm usingNinja
now.There is my profile:
I finally generated the
compile_commands.json
file, but it doesn't seem to include the conan installed dependencies. It only tracks files in my workspace. So I still can't find the includePath of conan dependencies in VSCode.Also I need to run
conanbuild.bat
before building cmake, otherwise myNinja
generator won't findc1.exe
in my enviroment. I wish it also has another solution.Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: