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

CMake: Compile Active File command stopped working in v1.9.0 #2180

Closed
aliaksei-bahdanau opened this issue Oct 15, 2021 · 6 comments
Closed
Labels
bug a bug in the product Feature: build
Milestone

Comments

@aliaksei-bahdanau
Copy link

Brief Issue Summary

CMake: Compile Active File command stopped working in v1.9.0. Tried on Lunux and Windows
Shows error: "Unable to find compilation information for this file"

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.61.1",
  "cmtVersion": "1.9.0",
  "configurations": [
    {
      "folder": "e:\\Users\\projects\\cpp",
      "cmakeVersion": "3.13.5",
      "configured": true,
      "generator": "MinGW Makefiles",
      "usesPresets": false,
      "compilers": {
        "C": "C:/mingw/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/gcc.exe",
        "CXX": "C:/mingw/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "requests": [],
    "responses": [],
    "targetCount": 3,
    "executablesCount": 1,
    "librariesCount": 2,
    "targets": [
      {
        "name": "main",
        "type": "EXECUTABLE"
      },
      {
        "name": "handler",
        "type": "SHARED_LIBRARY"
      },
      {
        "name": "core",
        "type": "SHARED_LIBRARY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[main] Saving open files before configure/build
[extension] [1581] cmake.compileFile finished (returned undefined)
@andreeis
Copy link
Contributor

andreeis commented Oct 15, 2021

@aliaksei-bahdanau, thank you for opening this bug. I am investigating and we will definitely fix this for a soon quick patch update 1.9.1. And we will send you a vsix with a fix even before that, to unblock you faster.
I notice that for presets off this still works as before. Maybe it's an acceptable workaround for you until you get a fix.

EDIT2: It works if you define "cmake.copyCompileCommands" or "cmake.mergedCompileCommands".
For presets on, you also need to have this in your configure preset:
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
}

@stilllman
Copy link

Hi, I'm not sure if it's related but I have an issue with the "compile active file" action even after applying your workaround (enabling cmake.copyCompileCommands): when running the action, a compile command is pasted in the terminal but not truncated (and not executed). Interestingly, the command is truncated at 1024 characters, which doesn't seem like a coincidence 😄. Is it related to the issue at hand? Should I report a separate issue?

Note that I've never tried this action before today, so I can't say if it was working before v1.9.0.

@stilllman
Copy link

Hi, I'm not sure if it's related but I have an issue with the "compile active file" action even after applying your workaround (enabling cmake.copyCompileCommands): when running the action, a compile command is pasted in the terminal but not truncated (and not executed). Interestingly, the command is truncated at 1024 characters, which doesn't seem like a coincidence 😄. Is it related to the issue at hand? Should I report a separate issue?

Note that I've never tried this action before today, so I can't say if it was working before v1.9.0.

Nevermind it seems unrelated to this issue and probably out of your control: microsoft/vscode#38137

@andreeis
Copy link
Contributor

@stilllman, you are right, this is a VSCode bug and we had users that reported this before. See this closed GitHub issue.
We can still work around this VSCode problem and we have this open issue that we didn't get to address yet.

@bobbrow bobbrow added this to the 1.9.1 milestone Oct 22, 2021
@andreeis
Copy link
Contributor

@aliaksei-bahdanau, a fix for this problem was included in the CMake Tools 1.9.1 release. Upgrade your extension in VSCode and let us know if you encounter any other issues.

@vdilecce
Copy link

vdilecce commented Dec 9, 2021

I am experiencing the same issue with the latest updates:

OS: Fedora 35
Compiler: GCC 11.2
CMake: 3.22.0
VSCode: 1.63.0
CMake Tools: 1.9.2

settings.json:

{
  "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
  "cmake.loggingLevel": "debug",
  "cmake.skipConfigureIfCachePresent": true,
  "cmake.useCMakePresets": "always"
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.22)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
project(HELLO LANGUAGES CXX)
add_executable(hello main.cpp)

CMakePresets.json:

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 22,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "linux-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    },
    {
      "name": "multi-config-base",
      "binaryDir": "buildc",
      "hidden": true
    },
    {
      "name": "linux-ninja-multi-config",
      "generator": "Ninja Multi-Config",
      "displayName": "Ninja",
      "description": "Multi-Config",
      "inherits": [
        "linux-base",
        "multi-config-base"
      ]
    }
  ],
  "buildPresets": [
    {
      "name": "linux-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    },
    {
      "name": "debug-base",
      "configuration": "Debug",
      "hidden": true
    },
    {
      "name": "release-base",
      "configuration": "Release",
      "hidden": true
    },
    {
      "name": "relwithdebinfo-base",
      "configuration": "RelWithDebInfo",
      "hidden": true
    },
    {
      "name": "linux-ninja-multi-config-debug",
      "configurePreset": "linux-ninja-multi-config",
      "displayName": "Debug",
      "inherits": [
        "linux-base",
        "debug-base"
      ]
    },
    {
      "name": "linux-ninja-multi-config-release",
      "configurePreset": "linux-ninja-multi-config",
      "displayName": "Release",
      "inherits": [
        "linux-base",
        "release-base"
      ]
    },
    {
      "name": "linux-ninja-multi-config-relwithdebinfo",
      "configurePreset": "linux-ninja-multi-config",
      "displayName": "RelWithDebInfo",
      "inherits": [
        "linux-base",
        "relwithdebinfo-base"
      ]
    }
  ]
}

main.cpp:

#include <iostream>

int
main(int argc, char* argv[])
{
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

When I run the "CMake: Compile Active File" from the command palette or when I right-click the source file in the CMake outline and choose "Compile File", I get the following in the Output window:

[extension] [4031] cmake.compileFile finished (returned undefined)

@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: build
Projects
None yet
Development

No branches or pull requests

5 participants