microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 455 forks source link

cmake-tools keeps sending hint "language modes specified are incompatible" to cpp-tools #2881

Open paulzhn opened 1 year ago

paulzhn commented 1 year ago

Brief Issue Summary

The error squiggle exists on the first line of every .c file and it shows the hint "language modes specified are incompatible". At first, I thought the problem was from cpp-tools, however after I changed configurationProvider to None, the problem had gone.

I found an issue with cpp-tools https://github.com/microsoft/vscode-cpptools/issues/9684, and it said the problem was that configurationProvider sends the wrong command to cpp-tools. So maybe the problem is from cmake-tools?

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.73.1",
  "cmtVersion": "1.12.27",
  "configurations": [
    {
      "folder": "/home/xieyun/code/agent-libs",
      "cmakeVersion": "3.22.1",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///home/xieyun/code/agent-libs/driver/main.c",
      "file:///home/xieyun/code/agent-libs/driver/ppm_cputime.c"
    ],
    "responses": [],
    "partialMatches": [],
    "targetCount": 23,
    "executablesCount": 4,
    "librariesCount": 6,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Configuring folder: agent-libs 
[main] Saving open files before configure/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[driver] Using compilers in GCC 11.3.0 x86_64-linux-gnu for configure
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake /usr/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc","-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++","-S/home/xieyun/code/agent-libs","-B/home/xieyun/code/agent-libs/build","-G","Unix Makefiles"]
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/xieyun/code/agent-libs -B/home/xieyun/code/agent-libs/build -G "Unix Makefiles"
[cmake] CMake Deprecation Warning at CMakeLists.txt:34 (cmake_minimum_required):
[cmake]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[cmake]   CMake.
[cmake] 
[cmake]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake]   CMake that the project does not need compatibility with older versions.
[cmake] 
[cmake] 
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Warning (dev) at CMakeLists.txt:36 (project):
[cmake]   Policy CMP0048 is not set: project() command manages VERSION variables.
[cmake]   Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
[cmake]   command to set the policy and suppress this warning.
[cmake] 
[cmake]   The following variable(s) would be set to empty:
[cmake] 
[cmake]     CMAKE_PROJECT_VERSION
[cmake]     CMAKE_PROJECT_VERSION_MAJOR
[cmake]     CMAKE_PROJECT_VERSION_MINOR
[cmake]     CMAKE_PROJECT_VERSION_PATCH
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- Using bundled zlib in '/home/xieyun/code/agent-libs/build/zlib-prefix/src/zlib'
[cmake] -- Using bundled tbb in '/home/xieyun/code/agent-libs/build/tbb-prefix/src/tbb'
[cmake] -- Using bundled b64 in '/home/xieyun/code/agent-libs/build/b64-prefix/src/b64'
[cmake] -- Using bundled jq in '/home/xieyun/code/agent-libs/build/jq-prefix/src/jq'
[cmake] -- Bundled jq: include: /home/xieyun/code/agent-libs/build/jq-prefix/src/jq/target/include, lib: /home/xieyun/code/agent-libs/build/jq-prefix/src/jq/target/lib/libjq.a
[cmake] -- Using bundled jsoncpp in '/home/xieyun/code/agent-libs/cmake/modules/../../userspace/libsinsp/third-party/jsoncpp'
[cmake] -- Using bundled c-ares in '/home/xieyun/code/agent-libs/build/c-ares-prefix/src/c-ares'
[cmake] -- Using bundled openssl in '/home/xieyun/code/agent-libs/build/openssl-prefix/src/openssl'
[cmake] -- Using bundled curl in '/home/xieyun/code/agent-libs/build/curl-prefix/src/curl'
[cmake] -- Using SSL for curl in '--with-ssl=/home/xieyun/code/agent-libs/build/openssl-prefix/src/openssl/target'
[cmake] -- Using bundled jsoncpp in '/home/xieyun/code/agent-libs/cmake/modules/../../userspace/libsinsp/third-party/jsoncpp'
[cmake] -- Using bundled protobuf in '/home/xieyun/code/agent-libs/build/protobuf-prefix/src/protobuf'
[cmake] -- Using bundled grpc in '/home/xieyun/code/agent-libs/build/grpc-prefix/src/grpc'
[cmake] -- Using bundled jsoncpp in '/home/xieyun/code/agent-libs/cmake/modules/../../userspace/libsinsp/third-party/jsoncpp'
[cmake] CMake Deprecation Warning at CMakeLists.txt:17 (cmake_minimum_required):
[cmake]   Compatibility with CMake < 2.8.12 will be removed from a future version of
[cmake]   CMake.
[cmake] 
[cmake]   Update the VERSION argument <min> value or use a ...<max> suffix to tell
[cmake]   CMake that the project does not need compatibility with older versions.
[cmake] 
[cmake] 
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/xieyun/code/agent-libs/build/googletest-download
[cmake] [ 11%] Performing update step for 'googletest'
[cmake] HEAD is now at a16bfcfd Disables `-Wunused-member-function` and `-Wused-but-marked-unused` that trigger via `MOCK_METHOD()` and `EXPECT_THAT()` macros.
[cmake] [ 22%] No patch step for 'googletest'
[cmake] [ 33%] No configure step for 'googletest'
[cmake] [ 44%] No build step for 'googletest'
[cmake] [ 55%] No install step for 'googletest'
[cmake] [ 66%] No test step for 'googletest'
[cmake] [ 77%] Completed 'googletest'
[cmake] [100%] Built target googletest
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/xieyun/code/agent-libs/build
[cmakefileapi-parser] Read reply folder: /home/xieyun/code/agent-libs/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-2625f1003b3af989f6da.json","cmakeFiles-v1-d1761cc587b7c067e62e.json","codemodel-v2-0d4540af946c091a9a34.json","directory-.-Debug-f5ebdc15457944623624.json","directory-driver-Debug-9eb2b321b14f5ae2cbc9.json","directory-driver.bpf-Debug-4718dc2a300008520d37.json","directory-googletest-build-Debug-ad89e8633cc40902e10f.json","directory-googletest-build.googlemock-Debug-615938ffd500e20b0ffb.json","directory-googletest-build.googletest-Debug-15b90499031de201d2f3.json","directory-libscap-Debug-f96d44d50126ff36deb1.json","directory-libscap.examples.01-open-Debug-19f5d6f26408fc363b85.json","directory-libscap.examples.02-validatebuffer-Debug-9aace973c8a61bfc28f0.json","directory-libsinsp-Debug-2a7820642db5776a2202.json","directory-libsinsp.examples-Debug-d72e5dcd259202b6c929.json","directory-libsinsp.test-Debug-ddbbe5b53a953f92bfeb.json","index-2022-12-02T08-27-23-0054.json","target-b64-Debug-eb7836b55930635c678d.json","target-c-ares-Debug-1bd3cf7b868d8205c430.json","target-curl-Debug-37b51f3b5b0f04fd7882.json","target-driver-Debug-b9de30f81609c7009033.json","target-gmock-Debug-60188a5e833b829be447.json","target-gmock_main-Debug-95eb647a6460ecd4a9ff.json","target-grpc-Debug-11062f22044b41545fe3.json","target-gtest-Debug-512c7d18c6fb6e635437.json","target-gtest_main-Debug-16203695ad55e69613f4.json","target-install_driver-Debug-05b6634b04d596b83b4e.json","target-jq-Debug-d40a86a81df0e30a9899.json","target-openssl-Debug-cd6016c8286d1f8b2a8e.json","target-protobuf-Debug-60a28a885488cf4d6dad.json","target-run-unit-test-libsinsp-Debug-5069e683fcc54aeb0c37.json","target-run-unit-tests-Debug-f8f57a4b76779996dd41.json","target-scap-Debug-a587c178a5e3165b8767.json","target-scap-open-Debug-8abd348c245e29cbaebd.json","target-scap-validatebuffer-Debug-b309d02a2f20569dd845.json","target-sinsp-Debug-7766d57736ed6d851e7e.json","target-sinsp-example-Debug-2cdc6f2475b682ae9f70.json","target-tbb-Debug-f6ae6c1e2ef2fe88b031.json","target-unit-test-libsinsp-Debug-15dee8260bdde44e9601.json","target-zlib-Debug-8930a56968bc72af9e16.json","toolchains-v1-074db5775ec40502811a.json"]
[cache] Reading CMake cache file /home/xieyun/code/agent-libs/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [6928] cmake.configure finished (returned 0)

Additional Information

The c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}",
                "/usr/src/linux-headers-5.15.0-52-generic/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            // "cStandard": "gnu17",
            // "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
elahehrashedi commented 1 year ago

Can you please run "C/C++: Log Diagnostics" and share the results with us?

elahehrashedi commented 1 year ago

It looks like that Cmake is not sending any configuration.

paulzhn commented 1 year ago

Can you please run "C/C++: Log Diagnostics" and share the results with us?

-------- Diagnostics - 12/3/2022, 2:45:13 PM
Version: 1.12.4
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}",
        "/usr/src/linux-headers-5.15.0-52-generic/include"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "intelliSenseMode": "linux-gcc-x64",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": true,
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "${workspaceFolder}",
            "/usr/src/linux-headers-5.15.0-52-generic/include"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "/home/xieyun/code/agent-libs/build/CMakeFiles",
        "/home/xieyun/code/agent-libs/build/b64-prefix/src/b64-stamp",
        "/home/xieyun/code/agent-libs/build/c-ares-prefix/src/c-ares-stamp",
        "/home/xieyun/code/agent-libs/build/curl-prefix/src/curl-stamp",
        "/home/xieyun/code/agent-libs/build/driver/CMakeFiles",
        "/home/xieyun/code/agent-libs/build/libsinsp/CMakeFiles",
        "/home/xieyun/code/agent-libs/build/grpc-prefix/src/grpc-stamp",
        "/home/xieyun/code/agent-libs/build/jq-prefix/src/jq-stamp",
        "/home/xieyun/code/agent-libs/build/openssl-prefix/src/openssl-stamp",
        "/home/xieyun/code/agent-libs/build/protobuf-prefix/src/protobuf-stamp",
        "/home/xieyun/code/agent-libs/build/libsinsp/test/CMakeFiles",
        "/home/xieyun/code/agent-libs/common",
        "/home/xieyun/code/agent-libs/build/zlib-prefix/src/zlib",
        "/home/xieyun/code/agent-libs/build/driver/src",
        "/home/xieyun/code/agent-libs/userspace/libscap",
        "/home/xieyun/code/agent-libs/driver",
        "/home/xieyun/code/agent-libs/userspace/common",
        "/home/xieyun/code/agent-libs/userspace/libscap/examples/01-open",
        "/home/xieyun/code/agent-libs/userspace/libscap/examples/02-validatebuffer",
        "/home/xieyun/code/agent-libs/build/tbb-prefix/src/tbb/include",
        "/home/xieyun/code/agent-libs/build/b64-prefix/src/b64/include",
        "/home/xieyun/code/agent-libs/build/jq-prefix/src/jq/target/include",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/third-party/jsoncpp",
        "/home/xieyun/code/agent-libs/build/c-ares-prefix/src/c-ares/target/include",
        "/home/xieyun/code/agent-libs/build/openssl-prefix/src/openssl/include",
        "/home/xieyun/code/agent-libs/build/curl-prefix/src/curl/include",
        "/home/xieyun/code/agent-libs/userspace/libsinsp",
        "/home/xieyun/code/agent-libs/userspace/async",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/include",
        "/home/xieyun/code/agent-libs/build/protobuf-prefix/src/protobuf/target/include",
        "/home/xieyun/code/agent-libs/build/grpc-prefix/src/grpc/target/include",
        "/home/xieyun/code/agent-libs/build/grpc-prefix/src/grpc/third_party/abseil-cpp",
        "/home/xieyun/code/agent-libs/build/libsinsp",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/container_engine",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/container_engine/docker",
        "/home/xieyun/code/agent-libs/userspace",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/examples",
        "/home/xieyun/code/agent-libs/build/tbb-prefix/src/tbb-stamp",
        "/home/xieyun/code/agent-libs/build/googletest-src/googletest/include/gtest",
        "/home/xieyun/code/agent-libs/build/googletest-src/googletest/include",
        "/home/xieyun/code/agent-libs/build/googletest-src/googletest",
        "/home/xieyun/code/agent-libs/userspace/libsinsp/test",
        "/home/xieyun/code/agent-libs/build/libscap/CMakeFiles",
        "/home/xieyun/code/agent-libs/build/zlib-prefix/src/zlib-stamp",
        "/home/xieyun/code/agent-libs/build/googletest-src/googlemock/include",
        "/home/xieyun/code/agent-libs/build/googletest-src/googlemock",
        "/home/xieyun/code/agent-libs/build/googletest-src/googlemock/src",
        "/home/xieyun/code/agent-libs/build/googletest-src/googletest/src"
    ],
    "compilerPath": "/usr/bin/g++",
    "compilerArgs": [],
    "compilerFragments": [
        " -Wall -ggdb -std=c++0x -D_DEBUG",
        "-Wall -Wshadow -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers"
    ]
}
No active translation units.

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3891
Number of files parsed: 164
paulzhn commented 1 year ago

FYI, the project is https://github.com/KindlingProject/agent-libs with the branch of kindling-dev

bobbrow commented 1 year ago

Thanks for sharing the project!

When I generate this project, CMake doesn't tell us about the files in the driver folder so we can't create a configuration for main.c etc. The problem seems to be that when you use include with modules and have those modules define targets, CMake doesn't write the source file configurations to the json files that we read from. As a result, we don't know how to configure IntelliSense and we don't give cpptools any information about the file.

I think you'll need to open an issue asking Kitware to include the source file configurations in what they call the "CMake File API". Once that is working, our extension will be able to provide the configurations. You can open a request here: https://gitlab.kitware.com/cmake/cmake/-/issues

robots commented 1 year ago

@paulzhn any update on the upstream issue ?