vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

`cmake.cacheInit` does not respect absolute paths in environment variables

Open Atry opened this issue 3 years ago • 3 comments

Brief Issue Summary

Reproducing steps

  1. Set environment variable CMAKE_INIT_CACHE to an absolute path, e.g. /tmp/my-init-cache.cmake
  2. Add the following setting in settings.json
    "cmake.cacheInit": "${env:CMAKE_INIT_CACHE}"
    
  3. Click "Configure All Projects" button

I expect the file /tmp/my-init-cache.cmake will be used to initialize CMake cache. Unfortunately the following command is invoked:

cmake ... -C /home/my-user/my-workspace//tmp/my-init-cache.cmake ...

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

Atry avatar Oct 07 '22 03:10 Atry

it looks like we are not expanding the path before we test if it is an absolute path.

Can you try using this setting and see if it works: "cmake.cacheInit": "/tmp/my-init-cache.cmake"

elahehrashedi avatar Oct 07 '22 16:10 elahehrashedi

The following setting works:

"cmake.cacheInit": "/tmp/my-init-cache.cmake"

Atry avatar Oct 07 '22 19:10 Atry

Workaround:

"cmake.cacheInit": "/${env:CMAKE_INIT_CACHE}"

then the following command will be executed:

cmake ... -C //tmp/my-init-cache.cmake ...

Atry avatar Oct 07 '22 19:10 Atry