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

Configure on Windows generates a faulty project #3922

Closed lucianthorr closed 4 months ago

lucianthorr commented 4 months ago

Brief Issue Summary

On Windows, I have a CMake based project where if I run cmake -SC:/project -BC:/project/build -G "Visual Studio 16 2019", it will generate a project that I can build. If I use the "Configure" button in the CMake Tools extension, it logs that it's running C:/Program Files/CMake/bin/cmake.exe" -SC:/project -BC:project/build/Windows -G "Visual Studio 16 2019" but the generated project ends up throwing tons of errors during the build process. Things like

C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h(100,1): error C2062: type 'wchar_t' unexpected 
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h(423,1): error C2059: syntax error: 'constant'

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.91.1",
  "cmtVersion": "1.18.43",
  "configurations": [
    {
      "folder": "c:\\Users\\username\\dev\\project",
      "cmakeVersion": "3.27.1",
      "configured": true,
      "generator": "Visual Studio 16 2019",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release"
    ],
    "requests": [
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp",
      "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/detail/juce_CheckSettingMacros.h"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/Users/username/dev/project/tests/source.cpp",
        "configuration": {
          "includePath": [
            "c:/users/username/dev/project/build/windows/project_artefacts/jucelibrarycode",
          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc",
            "/bigobj",
            "-w"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp",
        "configuration": {
          "includePath": [
            "c:/users/username/dev/project/build/windows/juce_binarydata_project_binarydata/jucelibrarycode"
          ],
          "defines": [
            "BUILD_VERSION=1",
            "CONFIGURATION_DEBUG=1",
            "_DEBUG=1"
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_ARA.cpp",
        "configuration": {
          "includePath": [
          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_LV2.cpp",
        "configuration": {
          "includePath": [
          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp",
        "configuration": {
          "includePath": [
          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp",
        "configuration": {
          "includePath": [
          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      },
      {
        "uri": "file:///c%3A/Users/username/dev/project/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp",
        "configuration": {
          "includePath": [

          ],
          "defines": [
          ],
          "compilerPath": "c:/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd",
            "/Od",
            "/Zi",
            "/MP",
            "/EHsc"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 16,
    "executablesCount": 1,
    "librariesCount": 9,
    "targets": [
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "project",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "project_All",
        "type": "UTILITY"
      },
      {
        "name": "project_BinaryData",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "project-core",
        "type": "INTERFACE_LIBRARY"
      },
      {
        "name": "project-core-assets",
        "type": "INTERFACE_LIBRARY"
      },
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "miniz",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "sqlite3",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "projectTests",
        "type": "EXECUTABLE"
      },
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "Catch2",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "Catch2WithMain",
        "type": "STATIC_LIBRARY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Configuring project: project 
[proc] Executing command: "C:/Program Files/CMake/bin/cmake.exe" -SC:/Users/username/dev/project -BC:/Users/username/dev/project/build/Windows -G "Visual Studio 16 2019"
[cmake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
[cmake] -- The C compiler identification is MSVC 19.29.30154.0
[cmake] -- The CXX compiler identification is MSVC 19.29.30154.0
[cmake] -- The ASM compiler identification is MSVC
[cmake] -- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring juceaide
[cmake] -- Building juceaide
[cmake] -- Exporting juceaide
[cmake] C:/Users/username/dev/project/build/Windows
[cmake] -- Configuring done (37.7s)
[cmake] -- Generating done (1.1s)
[cmake] -- Build files have been written to: C:/Users/username/dev/project/build/Windows

Additional Information

Considering the simplicity of the cmake command that generates the project successfully at the command line, I'm curious as to what the extension must be augmenting to generate a project that cannot build.

lucianthorr commented 4 months ago

User error, I think, by choosing a target that was not in the build preset's list of targets. Maybe that should not be allowed?