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

compile_commands 拆分带空格路径导致 clangd 不识别 #3256

Closed
finall1008 opened this issue Jan 6, 2023 · 3 comments
Closed

compile_commands 拆分带空格路径导致 clangd 不识别 #3256

finall1008 opened this issue Jan 6, 2023 · 3 comments

Comments

@finall1008
Copy link

Xmake 版本

2.7.4

操作系统版本和架构

Windows 11 Verison 22H2 Build 25272

描述问题

在 2.7.4 版本下,xmake 生成 compile_commands.json 时,如果编译器路径带有空格,会进行拆分,例如:

[
    {
        "directory": "C:\\Users\\ROG\\Documents\\Code\\graphics\\thss-animation-collision-detect",
        "arguments": [
            "C:\\Program",
            "Files\\NVIDIA",
            "GPU",
            "Computing",
            "Toolkit\\CUDA\\v12.0\\bin\\nvcc.exe",
            "-c",
            "-O3",
            ...

这造成 clangd 无法正确识别 compile_commands.json,表现为提示找不到任何 xmake 添加的第三方包 includes。

将路径重新组合后,问题解决:

[
    {
        "directory": "C:\\Users\\ROG\\Documents\\Code\\graphics\\thss-animation-collision-detect",
        "arguments": [
            "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.0\\bin\\nvcc.exe",
            "-c",
            "-O3",
            ...

期待的结果

clangd 正确识别 compile_commands.json

工程配置

add_rules("mode.debug", "mode.release")

add_requires("fmt", "glad ^0.1.34", "glfw ^3.3.4", "glm ^0.9.9", "spdlog", "stb", "imgui-docking", "range-v3")

add_cxxflags("-Wall")

if is_mode("release") then 
    set_optimize("fastest") 
end

if is_mode("debug") then
    add_cxxflags("-DDEBUG")
    add_cuflags("-DDEBUG")
end

set_languages("cxx20")

target("test")
    before_run(function (target)
        os.exec("xmake build")
    end)

    set_kind("binary")
    add_files("src/**.cu")
    add_files("src/**.cpp|algs/test.cpp")
    add_packages("fmt", "glad", "glfw", "glm", "spdlog", "stb", "imgui-docking", "range-v3")
    set_rundir('$(projectdir)')

    add_cuflags("-rdc=true")
    add_cuflags("--expt-relaxed-constexpr")
    add_cuflags("--extended-lambda")

    add_cugencodes("native")

附加信息和错误日志

No response

@finall1008 finall1008 added the bug label Jan 6, 2023
@finall1008
Copy link
Author

或许与 #3159 有关

@waruqi
Copy link
Member

waruqi commented Jan 6, 2023

看下 #3242 #3203

@finall1008
Copy link
Author

可以了,非常感谢!

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