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

hostSystemName is not expanded in CMakeUserPresets.json #2362

Closed
dvirtz opened this issue Feb 7, 2022 · 3 comments · Fixed by #2367
Closed

hostSystemName is not expanded in CMakeUserPresets.json #2362

dvirtz opened this issue Feb 7, 2022 · 3 comments · Fixed by #2367
Assignees
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@dvirtz
Copy link

dvirtz commented Feb 7, 2022

Brief Issue Summary

When using ${hostSystemName} in CMakeUserPresets.json it is left unexpanded by the extension.
I'm using the following CMakeUserPresets.json without a CMakePresets.json:

{
  "version": 3,
  "configurePresets": [
    {
      "name": "debug",
      "generator": "Unix Makefiles",
      "binaryDir": "${sourceDir}/build/${presetName}",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "HOST_NAME": "${hostSystemName}"
      }
    }
  ]
}

when I configure the project the command line shows ${hostSystemName} unexpanded

[proc] Executing command: /usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DHOST_NAME=${hostSystemName} -H/Users/dyitzchaki/github/bugs -B/Users/dyitzchaki/github/bugs/build/debug -G "Unix Makefiles"

Other macros seems to expand fine.
Running cmake manually does expand that macro:

% cmake --preset debug .
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  HOST_NAME="Darwin"

HOST_NAME = Darwin
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dyitzchaki/github/bugs/build/debug

A reproducing project can be found at https://github.com/dvirtz/bugs/tree/cmake-hostSystemName.

CMake Tools Diagnostics

{
  "os": "darwin",
  "vscodeVersion": "1.64.0",
  "cmtVersion": "1.9.2",
  "configurations": [
    {
      "folder": "/Users/dyitzchaki/github/bugs",
      "cmakeVersion": "3.22.1",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc",
        "CXX": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}
Debug Log
[main] Configuring folder: bugs 
[main] Saving open files before configure/build
[driver] Removing /Users/dyitzchaki/github/bugs/build/debug/CMakeCache.txt
[driver] Removing /Users/dyitzchaki/github/bugs/build/debug/CMakeFiles
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[driver] Start configure 
[driver] Runnnig pre-configure checks and steps
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake /usr/local/bin/cmake with arguments ["-DCMAKE_BUILD_TYPE=Debug","-DHOST_NAME=${hostSystemName}","-H/Users/dyitzchaki/github/bugs","-B/Users/dyitzchaki/github/bugs/build/debug","-G","Unix Makefiles"]
[proc] Executing command: /usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DHOST_NAME=${hostSystemName} -H/Users/dyitzchaki/github/bugs -B/Users/dyitzchaki/github/bugs/build/debug -G "Unix Makefiles"
[cmake] -- The C compiler identification is AppleClang 13.0.0.13000029
[cmake] -- The CXX compiler identification is AppleClang 13.0.0.13000029
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - 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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] HOST_NAME = ${hostSystemName}
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /Users/dyitzchaki/github/bugs/build/debug
[cmakefileapi-parser] Read reply folder: /Users/dyitzchaki/github/bugs/build/debug/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-d39f649706eb4284ad6b.json","codemodel-v2-7214efe1000663a2f82f.json","directory-.-Debug-f5ebdc15457944623624.json","index-2022-02-07T06-34-15-0763.json","toolchains-v1-ff5a8d0393c9d28f40b5.json"]
[cache] Reading CMake cache file /Users/dyitzchaki/github/bugs/build/debug/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [2793] cmake.cleanConfigure finished (returned 0)
@bobbrow
Copy link
Member

bobbrow commented Feb 8, 2022

Thank you for reporting this issue. There was a bug in the code determining whether to include ${hostSystemName} in the variable expansion. A PR is out with the fix.

@bobbrow bobbrow self-assigned this Feb 8, 2022
@bobbrow bobbrow added bug a bug in the product Feature: presets labels Feb 8, 2022
@bobbrow bobbrow added this to the 1.10.0 milestone Feb 8, 2022
@bobbrow
Copy link
Member

bobbrow commented Mar 1, 2022

The fix for this issue is available in 1.10 "pre-release". You can help us validate it by:

  1. Opening the extensions panel in VS Code
  2. Selecting the CMake Tools extension
  3. Clicking the "Switch to Pre-release Version" button

image

@dvirtz
Copy link
Author

dvirtz commented Mar 2, 2022

I can confirm the bug is resolved. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 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: presets
Projects
None yet
2 participants