vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Language server does not report path to SDK when using Xcode generator

Open alexbatalov opened this issue 11 months ago • 4 comments

Environment

  • OS and Version: macOS 14.5
  • VS Code Version: 1.96.4 (Universal)
  • C/C++ Extension Version: 1.23.5.0

Bug Summary and Steps to Reproduce

Minimal repo to reproduce: https://gist.github.com/alexbatalov/d364a78251d0c0d887a221a2cc0cf41f Select unix makefiles preset, observe there is no include error in the main.c. Select xcode preset, observe include error.

Configuration and Logs

All defaults (implying cmake-tools configuration provider).

Other Extensions

ms-vscode.cmake-tools (1.19.52)

Additional context

Here is diagnostics log from unix makefiles preset:

Version: 1.23.5
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Users/alex/dev/sample/**"
    ],
    "defines": [],
    "macFrameworkPath": [
        "/Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk/System/Library/Frameworks"
    ],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "macos-clang-x64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "/Users/alex/dev/sample/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "stdio.h": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
Custom browse configuration: 
{
    "browsePath": [
        "/users/alex/dev/sample"
    ],
    "compilerPath": "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/cc",
    "compilerArgs": [],
    "compilerFragments": [
        " -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk -mmacosx-version-min=14.5"
    ]
}
cpptools version (native): 1.23.5.0
Current database path: /Users/alex/Library/Caches/vscode-cpptools/574f383c91e984d4b69b86e95ab00552/.browse.VC.db
Translation Unit Mappings:
[ /Users/alex/dev/sample/main.c - source TU]:
Translation Unit Configurations:
[ /Users/alex/dev/sample/main.c ]
    Process ID: 4728
    Memory Usage: 15 MB
    Compiler Path: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/cc
    Includes:
    System Includes:
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/System/Library/Frameworks
    Standard Version: c17
    IntelliSense Mode: macos-clang-x64
    Other Flags:
        --clang
        --clang_version=170006
Total Memory Usage: 15 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3283

And here are for the xcode preset:

Version: 1.23.5
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Users/alex/dev/sample/**"
    ],
    "defines": [],
    "macFrameworkPath": [
        "/Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk/System/Library/Frameworks"
    ],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "macos-clang-x64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "/Users/alex/dev/sample/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "stdio.h": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
Custom browse configuration: 
{
    "browsePath": [
        "/users/alex/dev/sample/out/build/xcode/cmakefiles",
        "/users/alex/dev/sample"
    ],
    "compilerPath": "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang",
    "compilerArgs": [],
    "compilerFragments": [
        "-g"
    ]
}
cpptools version (native): 1.23.5.0
Current database path: /Users/alex/Library/Caches/vscode-cpptools/574f383c91e984d4b69b86e95ab00552/.browse.VC.db
Translation Unit Mappings:
[ /Users/alex/dev/sample/main.c - source TU]:
Translation Unit Configurations:
[ /Users/alex/dev/sample/main.c ]
    Process ID: 4774
    Memory Usage: 13 MB
    Compiler Path: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang
    Includes:
    System Includes:
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
    Frameworks:
        /System/Library/Frameworks
        /Library/Frameworks
    Standard Version: c17
    IntelliSense Mode: macos-clang-x64
    Other Flags:
        --clang
        --clang_version=170006
Total Memory Usage: 13 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 16640

Path to SDK (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/) is missing, hence include error. I'm not sure if that's vscode-cpptools or vscode-cmake-tools fault.

alexbatalov avatar Feb 05 '25 05:02 alexbatalov

Hi @alexbatalov,

Sorry we missed this issue earlier. Could you please provide the log output from the CMake: Log Diagnostics command for both presets as well? That should help us narrow down whether CMake Tools sent us the information or not. Please make sure that the sample main.c file is open in the editor first so that we can ensure that the configuration was sent.

bobbrow avatar Feb 21 '25 18:02 bobbrow

Here is the log for unix makefiles preset:

{
  "os": "darwin",
  "vscodeVersion": "1.97.0",
  "cmtVersion": "1.20.52",
  "configurations": [
    {
      "folder": "/Users/alex/dev/sample",
      "cmakeVersion": "3.31.4",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc",
        "CXX": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "",
    "buildTypesSeen": [
      ""
    ],
    "requests": [
      "file:///Users/alex/dev/sample/main.c"
    ],
    "responses": [
      {
        "uri": "file:///Users/alex/dev/sample/main.c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/cc",
          "compilerArgs": [],
          "compilerFragments": [
            " -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "sample",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Here is for the xcode preset:

{
  "os": "darwin",
  "vscodeVersion": "1.97.0",
  "cmtVersion": "1.20.52",
  "configurations": [
    {
      "folder": "/Users/alex/dev/sample",
      "cmakeVersion": "3.31.4",
      "configured": true,
      "generator": "Xcode",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release",
      "MinSizeRel",
      "RelWithDebInfo"
    ],
    "requests": [
      "file:///Users/alex/dev/sample/main.c"
    ],
    "responses": [
      {
        "uri": "file:///Users/alex/dev/sample/main.c",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang",
          "compilerArgs": [],
          "compilerFragments": [
            "-g"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 3,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "ZERO_CHECK",
        "type": "UTILITY"
      },
      {
        "name": "sample",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

alexbatalov avatar Feb 21 '25 19:02 alexbatalov

Thank you! This appears to be an issue with CMake not providing us with the sysroot when the XCode generator is used. I will transfer this to CMake Tools for them to follow up with Kitware.

bobbrow avatar Feb 21 '25 19:02 bobbrow

Hi @alexbatalov , thanks for reporting issue here! I can repro your issue on our side, following is the repro steps:

Repro Steps:

  1. Clone https://gist.github.com/alexbatalov/d364a78251d0c0d887a221a2cc0cf41f and open it with VS Code
  2. Open main.c file
  3. Select xcode preset, observe include error appear.

Image

@gcampbell-msft FYI

Amy-Li03 avatar Feb 26 '25 07:02 Amy-Li03