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

Intellisense fails to find Qt header files #2324

Closed
rectalogic opened this issue Jan 13, 2022 · 16 comments · Fixed by #3247
Closed

Intellisense fails to find Qt header files #2324

rectalogic opened this issue Jan 13, 2022 · 16 comments · Fixed by #3247
Assignees
Labels
Projects
Milestone

Comments

@rectalogic
Copy link

Brief Issue Summary

cmake-tools fails to find Qt header files. It appears to be sending an empty browsePath to cpp-tools

To reproduce on macOS 11.6.2 with Xcode 13.2.1:

$ git clone [email protected]:rectalogic/vscode-cmake.git
$ cd vscode-cmake
$ ./install-qt  # this requires python3, e.g. from brew

Then open vscode-cmake in vscode and configure cmake-tools.

vscode can successfully build the project, but if you open main.cpp it fails to find the Qt <QApplication> header.
header-not-found

CMake Tools Diagnostics

{
  "os": "darwin",
  "vscodeVersion": "1.63.2",
  "cmtVersion": "1.9.2",
  "configurations": [
    {
      "folder": "/Users/aw/Projects/rectalogic/vscode-cmake",
      "cmakeVersion": "3.22.1",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/clang",
        "CXX": "/usr/bin/clang++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///Users/aw/Projects/rectalogic/vscode-cmake/main.cpp"
    ],
    "responses": [
      {
        "uri": "file:///Users/aw/Projects/rectalogic/vscode-cmake/main.cpp",
        "configuration": {
          "defines": [
            "QT_CORE_LIB",
            "QT_GUI_LIB",
            "QT_WIDGETS_LIB"
          ],
          "standard": "gnu++17",
          "includePath": [
            "/users/aw/projects/rectalogic/vscode-cmake/build/main_autogen/include",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework/headers",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework/headers",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework",
            "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework/headers"
          ],
          "compilerPath": "/usr/bin/clang++",
          "compilerArgs": [
            "-g",
            "-isysroot",
            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk",
            "-mmacosx-version-min=11.6",
            "-std=gnu++17"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 3,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "main",
        "type": "EXECUTABLE"
      },
      {
        "name": "main_autogen",
        "type": "UTILITY"
      },
      {
        "name": "main_autogen_timestamp_deps",
        "type": "UTILITY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

C/C++ Log Diagnostics

The Custom browse configuration has an empty browsePath, this may be the issue?

-------- Diagnostics - 1/13/2022, 6:20:38 PM
Version: 1.7.1
Current Configuration:
{
    "name": "Mac cmake",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "includePath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1",
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include",
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"
    ],
    "macFrameworkPath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
    ],
    "compilerArgs": [],
    "cStandard": "c17",
    "cppStandard": "c++98",
    "intelliSenseMode": "macos-clang-x64",
    "mergeConfigurations": false,
    "compilerPath": "/usr/bin/clang",
    "browse": {
        "path": [
            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1",
            "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include",
            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
            "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": []
}
Custom configurations:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]
{
    "defines": [
        "QT_CORE_LIB",
        "QT_GUI_LIB",
        "QT_WIDGETS_LIB"
    ],
    "standard": "gnu++17",
    "includePath": [
        "/users/aw/projects/rectalogic/vscode-cmake/build/main_autogen/include",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework/headers",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework/headers",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework/headers"
    ],
    "compilerPath": "/usr/bin/clang++",
    "compilerArgs": [
        "-g",
        "-isysroot",
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk",
        "-mmacosx-version-min=11.6",
        "-std=gnu++17"
    ]
}
Translation Unit Mappings:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]:
    /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp
Translation Unit Configurations:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]:
    Process ID: 34343
    Memory Usage: 4 MB
    Compiler Path: /usr/bin/clang++
    Includes:
        /Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/include
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework/Versions/A/Headers
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework/Versions/A/Headers
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework/Versions/A/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        QT_CORE_LIB
        QT_GUI_LIB
        QT_WIDGETS_LIB
    Standard Version: c++17
    IntelliSense Mode: macos-clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 4 MB

Debug Log

[main] Building folder: vscode-cmake 
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build all
[proc] Executing command: /opt/local/bin/cmake --build /Users/aw/Projects/rectalogic/vscode-cmake/build --config Debug --target all -j 18 --
[build] [1/4  25% :: 0.509] Automatic MOC and UIC for target main
[build] [3/4  50% :: 0.644] Building CXX object CMakeFiles/main.dir/main_autogen/mocs_compilation.cpp.o
[build] [3/4  75% :: 2.144] Building CXX object CMakeFiles/main.dir/main.cpp.o
[build] [4/4 100% :: 2.329] Linking CXX executable main
[cmakefileapi-parser] Read reply folder: /Users/aw/Projects/rectalogic/vscode-cmake/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-db17aa5346b3063312c4.json","codemodel-v2-f9968e0ef990a41bb4f5.json","directory-.-Debug-f5ebdc15457944623624.json","index-2022-01-13T23-09-19-0193.json","target-main-Debug-e405c207129ca950dff6.json","target-main_autogen-Debug-71586aa8a38f069c3446.json","target-main_autogen_timestamp_deps-Debug-0c5f526a5cac1370cfef.json","toolchains-v1-248d8c0a238b331e6ecf.json"]
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[cache] Reading CMake cache file /Users/aw/Projects/rectalogic/vscode-cmake/build/CMakeCache.txt
[cache] Parsing CMake cache string
[build] Build finished with exit code 0
[extension] [3702] cmake.build finished (returned 0)
@bobbrow
Copy link
Member

bobbrow commented Jan 14, 2022

vscode can successfully build the project, but if you open main.cpp it fails to find the Qt <QApplication> header.

Actually, QApplication is found, it is a dependency of QApplication that is not. The way that Apple Frameworks are normally included is of the form <Framework/Header> and in the screenshot it shows that <QtWidgets/qtwidgetsglobal.h> was not found. In order for this form to work, the path above the framework needs to be part of the include path because of how the includes work. However, I currently see that we're sending:

        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework/headers",

in the includePath which allows direct access to the header (e.g. the <QApplication> form) instead of the framework path

        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib",

which allows framework include syntax (e.g. the <QtWidgets/qtwidgetsglobal.h> form).

If you could poke into your build folder and share the json file CMake generated for this target, I can see whether this information is present or not (if not, this would be a CMake bug). Based on the information you've shared, I'd expect the file to be here: /Users/aw/Projects/rectalogic/vscode-cmake/build/.cmake/api/v1/reply/target-*-Debug.json

@rectalogic
Copy link
Author

CMake generated json files attached
cmake-json.zip

@rectalogic
Copy link
Author

I also tried adding "includePath": ["${workspaceFolder}/qt/6.2.2/macos/lib"] to c_cpp_properties.json and I see it is being sent in C/C++ Diagnostics but still the same header file error occurs.

-------- Diagnostics - 1/14/2022, 4:18:06 PM
Version: 1.7.1
Current Configuration:
{
    "name": "Mac cmake",
    "configurationProvider": "ms-vscode.cmake-tools",
    "includePath": [
        "${workspaceFolder}/qt/6.2.2/macos/lib"
    ],
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "macFrameworkPath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
    ],
    "compilerArgs": [],
    "cStandard": "c17",
    "cppStandard": "c++98",
    "intelliSenseMode": "macos-clang-x64",
    "mergeConfigurations": false,
    "compilerPath": "/usr/bin/clang",
    "browse": {
        "path": [
            "${workspaceFolder}/qt/6.2.2/macos/lib",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": []
}
Custom configurations:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]
{
    "defines": [
        "QT_CORE_LIB",
        "QT_GUI_LIB",
        "QT_WIDGETS_LIB"
    ],
    "standard": "gnu++17",
    "includePath": [
        "/users/aw/projects/rectalogic/vscode-cmake/build/main_autogen/include",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtcore.framework/headers",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtwidgets.framework/headers",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework",
        "/users/aw/projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/qtgui.framework/headers"
    ],
    "compilerPath": "/usr/bin/clang++",
    "compilerArgs": [
        "-g",
        "-isysroot",
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk",
        "-mmacosx-version-min=11.6",
        "-std=gnu++17"
    ]
}
Translation Unit Mappings:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]:
    /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp
Translation Unit Configurations:
[ /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp ]:
    Process ID: 51656
    Memory Usage: 4 MB
    Compiler Path: /usr/bin/clang++
    Includes:
        /Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/include
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework/Versions/A/Headers
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework/Versions/A/Headers
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework
        /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework/Versions/A/Headers
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Defines:
        QT_CORE_LIB
        QT_GUI_LIB
        QT_WIDGETS_LIB
    Standard Version: c++17
    IntelliSense Mode: macos-clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 4 MB

@bobbrow
Copy link
Member

bobbrow commented Jan 14, 2022

I don't see the framework path being added in the compile fragments in the JSON files. But I do see a reference to qt/6.2.2/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake. Could you share that?

I also tried adding "includePath": ["${workspaceFolder}/qt/6.2.2/macos/lib"] to c_cpp_properties.json and I see it is being sent in C/C++ Diagnostics but still the same header file error occurs.

This is because cpptools does not use your values for includePath when CMake Tools is providing the IntelliSense configuration. The Translation Unit Configurations: section of the log shows what was actually sent to the IntelliSense compiler.

@rectalogic
Copy link
Author

rectalogic commented Jan 14, 2022

qt/6.2.2/macos/lib/cmake/Qt6Core/Qt6CoreMacros.cmake
Qt6CoreMacros.cmake.txt

@bobbrow
Copy link
Member

bobbrow commented Jan 14, 2022

Thanks. I did see a place where the -F argument should be generated in some cases, but it doesn't appear in your JSON files for whatever reason. I wasn't able to parse through all that's going on in that file.

I did see a section related to MOC which appears to be QT's pre-C++ compiler. It's possible that the framework directory is "known" and therefore not surfaced on the command line. We might have to do some special casing for QT.

@rectalogic
Copy link
Author

I added "CMAKE_VERBOSE_MAKEFILE": "ON" to my "cmake.configureSettings" and rebuilt so we can see what actual include flags are being passed to the compiler since it is able to resolve these headers. It's passing -iframework /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib:

[main] Building folder: vscode-cmake 
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build all
[proc] Executing command: /opt/local/bin/cmake --build /Users/aw/Projects/rectalogic/vscode-cmake/build --config Debug --target all -j 18 --
[build] [1/4  25% :: 0.104] cd /Users/aw/Projects/rectalogic/vscode-cmake/build && /opt/local/bin/cmake -E cmake_autogen /Users/aw/Projects/rectalogic/vscode-cmake/build/CMakeFiles/main_autogen.dir/AutogenInfo.json Debug && /opt/local/bin/cmake -E touch /Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/timestamp && /opt/local/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /Users/aw/Projects/rectalogic/vscode-cmake /Users/aw/Projects/rectalogic/vscode-cmake /Users/aw/Projects/rectalogic/vscode-cmake/build /Users/aw/Projects/rectalogic/vscode-cmake/build /Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/deps /Users/aw/Projects/rectalogic/vscode-cmake/build/CMakeFiles/d/e95d927cbe282da8295d1f309d681135d47553508d22da943b9d959084eb4466.d
[build] [3/4  50% :: 0.155] /usr/bin/clang++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I/Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/include -iframework /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework/Headers -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework/Headers -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework/Headers -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -std=gnu++17 -MD -MT CMakeFiles/main.dir/main_autogen/mocs_compilation.cpp.o -MF CMakeFiles/main.dir/main_autogen/mocs_compilation.cpp.o.d -o CMakeFiles/main.dir/main_autogen/mocs_compilation.cpp.o -c /Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/mocs_compilation.cpp
[build] [3/4  75% :: 1.450] /usr/bin/clang++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I/Users/aw/Projects/rectalogic/vscode-cmake/build/main_autogen/include -iframework /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtCore.framework/Headers -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/mkspecs/macx-clang -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/include -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtWidgets.framework/Headers -isystem /Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib/QtGui.framework/Headers -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -std=gnu++17 -MD -MT CMakeFiles/main.dir/main.cpp.o -MF CMakeFiles/main.dir/main.cpp.o.d -o CMakeFiles/main.dir/main.cpp.o -c /Users/aw/Projects/rectalogic/vscode-cmake/main.cpp
[build] [4/4 100% :: 1.613] : && /usr/bin/clang++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/main.dir/main_autogen/mocs_compilation.cpp.o CMakeFiles/main.dir/main.cpp.o -o main  -Wl,-rpath,/Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib  ../qt/6.2.2/macos/lib/QtWidgets.framework/Versions/A/QtWidgets  ../qt/6.2.2/macos/lib/QtGui.framework/Versions/A/QtGui  ../qt/6.2.2/macos/lib/QtCore.framework/Versions/A/QtCore  -framework DiskArbitration  -framework IOKit  -framework  OpenGL  -framework  AGL  -framework AppKit  -framework ImageIO  -framework Metal && :
[cmakefileapi-parser] Read reply folder: /Users/aw/Projects/rectalogic/vscode-cmake/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-85389d99c2ebc073af97.json","codemodel-v2-f9968e0ef990a41bb4f5.json","directory-.-Debug-f5ebdc15457944623624.json","index-2022-01-14T23-19-42-0813.json","target-main-Debug-e405c207129ca950dff6.json","target-main_autogen-Debug-71586aa8a38f069c3446.json","target-main_autogen_timestamp_deps-Debug-0c5f526a5cac1370cfef.json","toolchains-v1-248d8c0a238b331e6ecf.json"]
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[build] Build finished with exit code 0
[extension] [6958] cmake.build finished (returned 0)

@bobbrow
Copy link
Member

bobbrow commented Jan 14, 2022

Unfortunately that information is not in the JSON files we use to configure IntelliSense so we'll have to work around it. It looks like this was already reported to Kitware, but the issue has not been addressed. https://gitlab.kitware.com/cmake/cmake/-/issues/19897

@rectalogic
Copy link
Author

I manually added the framework path to the "includes" section of /Users/aw/Projects/rectalogic/vscode-cmake/build/.cmake/api/v1/reply/target-main-Debug-*.json and confirmed that does fix the Intellisense issue.

                {
                    "backtrace" : 5,
                    "path" : "/Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib"
                }

@Mactarvish
Copy link

I manually added the framework path to the "includes" section of /Users/aw/Projects/rectalogic/vscode-cmake/build/.cmake/api/v1/reply/target-main-Debug-*.json and confirmed that does fix the Intellisense issue.

                {
                    "backtrace" : 5,
                    "path" : "/Users/aw/Projects/rectalogic/vscode-cmake/qt/6.2.2/macos/lib"
                }

Same issue, but this method doesn't work for me.

@Mactarvish
Copy link

I've noticed that on Mac Qt uses Framework to organize its headers, which uses Clang Module to search header path instead of the real path, that maybe the reason why cmake cannot find it.

@jctaoo
Copy link

jctaoo commented Apr 16, 2023

{
  "configurations": [
    {
      "name": "Mac",
      "includePath": [
        "${workspaceFolder}/**",
        "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Headers/",
        "${workspaceFolder}/packages/libuiohook/include/",
        "${workspaceFolder}/packages/clip/",
        "/usr/local/Cellar/qt@5/5.15.8_2/lib/QtWidgets.framework/Headers/",
        "/usr/local/Cellar/qt@5/5.15.8_2/lib/QtWidgets.framework/",
        "/usr/local/Cellar/qt@5/5.15.8_2/include/"
      ],
      "defines": [],
      "macFrameworkPath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
      ],
      "compilerPath": "/usr/bin/clang",
      "cStandard": "c17",
      "cppStandard": "c++17",
      "intelliSenseMode": "macos-clang-x64",
      "configurationProvider": "ms-vscode.cmake-tools"
    }
  ],
  "version": 4
}

This is my c_cpp_properties.json and vscode can find <QApplication> and my version of cmake-tools is v1.13.45 and my qt is installed by homebrew.

截屏2023-04-17 00 26 27

@wy-luke
Copy link

wy-luke commented Apr 17, 2023

This is my c_cpp_properties.json and vscode can find <QApplication> and my version of cmake-tools is v1.13.45 and my qt is installed by homebrew.

@jctaoo Yeah, you specified the QtWidgets.framework/Headers path in the JSON file.

I tried adding .../lib/QtCore.framework/Headers/** but it just worked for QApplication. Other packages like <QLocale>, <QTranslator> and so on are still cannot open source file.....

Strangely, after I command+click on <QLocale> to open the qlocale.h file and wait a second, the error disappeared, while the QApplication cannot be opened again.

The same thing happened to other packages as well. I'm not sure why or how this happened.

截屏2023-04-17 22 21 38

截屏2023-04-17 22 22 49

Btw, after switching to the clangd extension in VSCode, it works well without needing any configuration.

@rectalogic
Copy link
Author

Unfortunately that information is not in the JSON files we use to configure IntelliSense so we'll have to work around it. It looks like this was already reported to Kitware, but the issue has not been addressed. https://gitlab.kitware.com/cmake/cmake/-/issues/19897

@bobbrow Looks like that issue was recently resolved by a change to the CMake codemodel.

@benmcmorran benmcmorran added this to Triage in 1.15 via automation May 30, 2023
@benmcmorran benmcmorran added this to the 1.15 milestone May 30, 2023
@benmcmorran benmcmorran moved this from Triage to To do in 1.15 May 30, 2023
@benmcmorran
Copy link
Member

@rectalogic Thanks for pointing that out. We'll work on incorporating the File API changes from CMake 3.27 in our 1.15 extension release.

@benmcmorran
Copy link
Member

I've tested #3247 with the repro project in the original post and everything seems to be working now. This fix will ship in version 1.15, which we expect to release around the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
1.15
Done
Development

Successfully merging a pull request may close this issue.

6 participants