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 Presets - Architecture field ignored during configuration #4181

Open
joelkeeling opened this issue Nov 20, 2024 · 2 comments · May be fixed by #4208
Open

CMake Presets - Architecture field ignored during configuration #4181

joelkeeling opened this issue Nov 20, 2024 · 2 comments · May be fixed by #4208
Assignees
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@joelkeeling
Copy link

joelkeeling commented Nov 20, 2024

Brief Issue Summary

When using the cmake tools extension, I am unable to change the target architecture(x86/x64) with the "architecture" field in my configure preset. This functionality does work if I use cmake over the command line.

In the example, I am trying use the "debug-32bit" preset, which is supposed to build for x86.

  • In the extension output, you can see the compiler under Hostx64/x64/cl.exe is selected
  • In the command line cmake output, you can see the compiler under Hostx64/x86/cl.exe is selected

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.95.1",
  "cmtVersion": "1.20.24",
  "configurations": [
    {
      "folder": "c:\\Users\\TEST\\cmakePresetTestProject",
      "cmakeVersion": "3.31.0",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug",
      "Release",
      "MinSizeRel",
      "RelWithDebInfo"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 3,
    "executablesCount": 0,
    "librariesCount": 1,
    "targets": [
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "SctTest",
        "type": "SHARED_LIBRARY"
      },
      {
        "name": "ZERO_CHECK",
        "type": "UTILITY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Configuring project: cmakePresetTestProject 
[driver] Removing C:/Users/TEST/cmakePresetTestProject/out/build/debug-32bit/CMakeCache.txt
[driver] Removing C:\Users\TEST\cmakePresetTestProject\out\build\debug-32bit\CMakeFiles
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE=Debug -SC:/Users/TEST/cmakePresetTestProject -BC:/Users/TEST/cmakePresetTestProject/out/build/debug-32bit
[cmake] -- Building for: Visual Studio 17 2022
[cmake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
[cmake] -- The CXX compiler identification is MSVC 19.39.33522.0
[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/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring done (2.9s)
[cmake] CMake Warning:
[cmake]   Manually-specified variables were not used by the project:
[cmake] 
[cmake]     CMAKE_BUILD_TYPE
[cmake] 
[cmake] 
[cmake] -- Generating done (0.2s)
[cmake] -- Build files have been written to: C:/Users/TEST/cmakePresetTestProject/out/build/debug-32bit

Additional Information

This is a follow up to a comment I made to @gcampbell-msft : #3818 (comment)

PRESETS

"configurePresets": [        
        {
            "name": "base-64bit",
            "hidden": true,
            "architecture": 
            {
                "value": "x64",
                "strategy": "set"
            }
        },
        {
            "name": "base-32bit",
            "hidden": true,
            "architecture": 
            {
                "value": "Win32",
                "strategy": "set"
            }
        },
        {
            "name": "base-debug",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "base-release",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Release"
            }
        },
        {
            "name": "debug-32bit",
            "inherits": [
                "base-32bit",
                "base-debug"       
            ]
        },
        {
            "name": "debug-64bit",
            "inherits": [
                "base-64bit",
                "base-debug"       
            ]
        },
        {
            "name": "release-32bit",
            "inherits": [
                "base-32bit",
                "base-release"       
            ]
        },
        {
            "name": "release-64bit",
            "inherits": [
                "base-64bit",
                "base-release"       
            ]
        }
    ],

CORRECT FUNCTIONALITY USING COMMAND LINE

PS C:\Users\TEST\cmakePresetTestProject\build> cmake ../ --preset debug-32bit
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.39.33522.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (2.5s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE


-- Build files have been written to: C:/Users/TEST/cmakePresetTestProject/build
@Amy-Li03
Copy link
Collaborator

Hi @joelkeeling, thanks for your feedback ticket!
We can repro this issue on our side with below:

Environment:

VS Code: 1.95.3
CMake Tools: v1.20.25 (pre-release)

Repro steps:

  1. Unzip the project and open it with vscode. test_project.zip
  2. Open the command palette (F1 or Ctrl+Shift+P)
  3. Enter and select the command CMake: Configure
  4. Choose "debug-32bit"
  5. Observe the messages in OUTPUT window

Test result:

CMake configure is executed from VSCode via cmake tools extension.
Image

CMake configure is executed from command line. (cmake ../ --preset debug-32bit)
Image

@Amy-Li03 Amy-Li03 added bug a bug in the product Feature: presets and removed triage labels Nov 21, 2024
@gcampbell-msft gcampbell-msft moved this from Blocked to Pending Prioritization in CMake Tools Nov 21, 2024
@gcampbell-msft gcampbell-msft added this to the 1.20 milestone Nov 21, 2024
@gcampbell-msft gcampbell-msft self-assigned this Dec 9, 2024
@gcampbell-msft
Copy link
Collaborator

@joelkeeling I've taken a look, and this is happening because you don't have a generator set. This is a bug on our end, but to workaround it, you can simply set a generator in your preset, and it should work as expected.

However, we plan to implement a fix for this, since after v3 of CMake Presets, the generator field is optional this should work. We are targeting the 1.20 release for this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: presets
Projects
Status: In Progress
3 participants