Skip to content

CMake configure preset installDir setting is evaluated relative to the binary directory instead of the source directory #3871

@Bekenn

Description

@Bekenn

Brief Issue Summary

From the CMake documentation for the installDir setting:

If a relative path is specified, it is calculated relative to the source directory.

The CMake Tools extension appears to evaluate this setting relative to the binary directory. If I supply a relative path and run the configure task using the CMake Tools extension, then the resulting cache variable for CMAKE_INSTALL_PREFIX begins with the binary directory. If I instead invoke CMake directly with the same preset, then CMAKE_INSTALL_PREFIX begins with the source directory.

My best guess as to the cause is that the extension runs the configure step with the current working directory set to the binary directory. Passing a relative path with -DCMAKE_INSTALL_PREFIX= will cause CMake to form a path relative to the current working directory rather than the source directory. The CMake Tools extension should explicitly prepend the source directory in this case.

CMake Tools Diagnostics

{
  "os": "darwin",
  "vscodeVersion": "1.91.0",
  "cmtVersion": "1.18.42",
  "configurations": [
    {
      "folder": "/Users/bekenn/Projects/altsup",
      "cmakeVersion": "3.29.3",
      "configured": true,
      "generator": "Ninja Multi-Config",
      "usesPresets": true,
      "compilers": {
        "CXX": "/opt/homebrew/opt/llvm/bin/clang++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[expand] expanding cmake
[main] Configuring project: altsup 
[main] Saving open files before configure/build
[expand] expanding /Users/bekenn/Projects/altsup
[driver] Start configure 
[driver] Running pre-configure checks and steps
[expand] expanding /Users/bekenn/Projects/altsup
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake /usr/local/bin/cmake with arguments ["-DCMAKE_CXX_COMPILER:FILEPATH=/opt/homebrew/opt/llvm/bin/clang++","-DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++","-DCMAKE_EXPORT_COMPILE_COMMANDS=true","-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=true","-DCMAKE_TOOLCHAIN_FILE=/Users/bekenn/.vcpkg/scripts/buildsystems/vcpkg.cmake","-DCMAKE_INSTALL_PREFIX=install","-S/Users/bekenn/Projects/altsup","-B/Users/bekenn/Projects/altsup/build","-G","Ninja Multi-Config"]
[proc] Executing command: /usr/local/bin/cmake -DCMAKE_CXX_COMPILER:FILEPATH=/opt/homebrew/opt/llvm/bin/clang++ "-DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++" -DCMAKE_EXPORT_COMPILE_COMMANDS=true -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=true -DCMAKE_TOOLCHAIN_FILE=/Users/bekenn/.vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=install -S/Users/bekenn/Projects/altsup -B/Users/bekenn/Projects/altsup/build -G "Ninja Multi-Config"
[proc]   with environment: {"CLICOLOR":"1","CMAKE_EXPORT_COMPILE_COMMANDS":"ON","CMAKE_GENERATOR":"Ninja Multi-Config","COMMAND_MODE":"unix2003","HOME":"/Users/bekenn","HOMEBREW_CELLAR":"/opt/homebrew/Cellar","HOMEBREW_PREFIX":"/opt/homebrew","HOMEBREW_REPOSITORY":"/opt/homebrew","INFOPATH":"/opt/homebrew/share/info:","LOGNAME":"bekenn","MANPATH":"/opt/homebrew/share/man::","MallocNanoZone":"0","OLDPWD":"/","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PATH":"/Users/bekenn/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin","PWD":"/","SHELL":"/bin/zsh","SHLVL":"0","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.1qiwkR24zg/Listeners","TMPDIR":"/var/folders/j4/2kqn79j96m9_c04c4s2x1wqh0000gn/T/","USER":"bekenn","VCPKG_ROOT":"/Users/bekenn/.vcpkg","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"/Users/bekenn/Library/Application Support/Code/CachedData/ea1445cc7016315d0f5728f8e8b12a45dc0a7286","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/bekenn/Library/Application Support/Code/1.91-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"13709","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.48121787.48121793","_":"/Applications/Visual Studio Code.app/Contents/MacOS/Electron","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[cmake] -- Running vcpkg install
[cmake] warning: Embedding `vcpkg-configuration` in a manifest file is an EXPERIMENTAL feature.
[cmake] Detecting compiler hash for triplet arm64-osx...
[cmake] Compiler found: /Library/Developer/CommandLineTools/usr/bin/c++
[cmake] All requested packages are currently installed.
[cmake] Total install time: 292 ns
[cmake] catch2 provides CMake targets:
[cmake] 
[cmake]   # this is heuristically generated, and may not be correct
[cmake]   find_package(Catch2 CONFIG REQUIRED)
[cmake]   target_link_libraries(main PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
[cmake] 
[cmake] catch2 provides pkg-config modules:
[cmake] 
[cmake]   # A modern, C++-native test framework for C++14 and above (links in default main)
[cmake]   catch2-with-main
[cmake] 
[cmake]   # A modern, C++-native, test framework for C++14 and above
[cmake]   catch2
[cmake] 
[cmake] -- Running vcpkg install - done
[cmake] -- Configuring done (2.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /Users/bekenn/Projects/altsup/build
[cmakefileapi-parser] Read reply folder: /Users/bekenn/Projects/altsup/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-4c19f03a7375dc3f2c5f.json","cmakeFiles-v1-3841a8f88284b87161ca.json","codemodel-v2-17c2bbf6c838be2c90f9.json","directory-.-Debug-f5ebdc15457944623624.json","directory-.-RelWithDebInfo-f5ebdc15457944623624.json","directory-.-Release-64ece4f42f578468ab26.json","index-2024-07-04T19-54-53-0471.json","target-Continuous-Debug-f6c7b0f6cbd4c55a4d11.json","target-Continuous-RelWithDebInfo-92952260c3baf931ee7d.json","target-Continuous-Release-0e70209f289eb4598930.json","target-ContinuousBuild-Debug-006fda569592d10d24b2.json","target-ContinuousBuild-RelWithDebInfo-08321420ab7f72ca5de0.json","target-ContinuousBuild-Release-533b3f22c9f3cef149c0.json","target-ContinuousConfigure-Debug-a857cb2702ffa0b40767.json","target-ContinuousConfigure-RelWithDebInfo-53c530cbc1d2e2b928a3.json","target-ContinuousConfigure-Release-477bbadf8521b4584fe9.json","target-ContinuousCoverage-Debug-d40a3a72f2ea5ea44fc9.json","target-ContinuousCoverage-RelWithDebInfo-990aa4feb869641436cf.json","target-ContinuousCoverage-Release-fbd270e4d40cfc25ebfa.json","target-ContinuousMemCheck-Debug-34c62ba5933a8c7a59da.json","target-ContinuousMemCheck-RelWithDebInfo-3243ef6ddc78c6dcca8e.json","target-ContinuousMemCheck-Release-acb65659f9d3c5ad3578.json","target-ContinuousStart-Debug-c8f41c9fc37f5ceb00a4.json","target-ContinuousStart-RelWithDebInfo-636ee29c766e9798344a.json","target-ContinuousStart-Release-e13eb391934f5be4ad4f.json","target-ContinuousSubmit-Debug-8ab1c503cd313d9cb90d.json","target-ContinuousSubmit-RelWithDebInfo-d819dfe49a39e3323935.json","target-ContinuousSubmit-Release-c89c603284018ff57eee.json","target-ContinuousTest-Debug-d87a526d4c76d21b74ba.json","target-ContinuousTest-RelWithDebInfo-b45b2467e9c7975a6ef0.json","target-ContinuousTest-Release-a34a30e0e3e8ba57d9db.json","target-ContinuousUpdate-Debug-780d426eb3f8c766452a.json","target-ContinuousUpdate-RelWithDebInfo-092cc7df061dcbb85d08.json","target-ContinuousUpdate-Release-5da87274b175b68050fa.json","target-Experimental-Debug-181d3abb3091652d2819.json","target-Experimental-RelWithDebInfo-d4fcf41635923bc74fdd.json","target-Experimental-Release-5f536a9247bc59910210.json","target-ExperimentalBuild-Debug-5cc2e223ccec88f94e5a.json","target-ExperimentalBuild-RelWithDebInfo-b13a61b2326792ab93bb.json","target-ExperimentalBuild-Release-7f165d84f2e160545dd6.json","target-ExperimentalConfigure-Debug-165d8b6e1a7c54d2f813.json","target-ExperimentalConfigure-RelWithDebInfo-877fe434bd3d0a54e50f.json","target-ExperimentalConfigure-Release-bb6720873dfd367b4d92.json","target-ExperimentalCoverage-Debug-08d2b747eca1f0e8b344.json","target-ExperimentalCoverage-RelWithDebInfo-6e501afedbbf613df56c.json","target-ExperimentalCoverage-Release-d860e471043cf40ffd53.json","target-ExperimentalMemCheck-Debug-ea4070411026249b1bdc.json","target-ExperimentalMemCheck-RelWithDebInfo-da25626412352ee2b3fd.json","target-ExperimentalMemCheck-Release-95ba34dabfe643f9a4ca.json","target-ExperimentalStart-Debug-46a8b97e276748132b76.json","target-ExperimentalStart-RelWithDebInfo-2fdb068bbe51b2ed3a86.json","target-ExperimentalStart-Release-2dc98d40ab7c5b4d8c5a.json","target-ExperimentalSubmit-Debug-347dabc725ef54f86b92.json","target-ExperimentalSubmit-RelWithDebInfo-bf1920e8276c88374feb.json","target-ExperimentalSubmit-Release-20fa4abfd56006e437b8.json","target-ExperimentalTest-Debug-ebdaa3b426b2c33e35af.json","target-ExperimentalTest-RelWithDebInfo-da49af087c75ad348d93.json","target-ExperimentalTest-Release-5ba7a01ae78c2383b749.json","target-ExperimentalUpdate-Debug-2f13fefdd2888998c701.json","target-ExperimentalUpdate-RelWithDebInfo-6e4ea5b36f9ba6bfe240.json","target-ExperimentalUpdate-Release-19a2f6d21bdf13e36ddf.json","target-Nightly-Debug-d470294d86079f32dec0.json","target-Nightly-RelWithDebInfo-d8c07d91af6fb8d02784.json","target-Nightly-Release-3ccdeaa40c4d35ec6a99.json","target-NightlyBuild-Debug-3742dfcd61d187a98285.json","target-NightlyBuild-RelWithDebInfo-b19d1ebc71d668ca8111.json","target-NightlyBuild-Release-07cd29bbcd306bc5d4d4.json","target-NightlyConfigure-Debug-5e708e78eebe13100efc.json","target-NightlyConfigure-RelWithDebInfo-f6fd43a5541813ee2a14.json","target-NightlyConfigure-Release-e86a908a6aa796a9e1d2.json","target-NightlyCoverage-Debug-87686e91367e5d9180ff.json","target-NightlyCoverage-RelWithDebInfo-b668a206d5a634554a56.json","target-NightlyCoverage-Release-ba7b76aad82e14d7202b.json","target-NightlyMemCheck-Debug-473ebe72356dcdec1519.json","target-NightlyMemCheck-RelWithDebInfo-7ef25570f2880e1b3eae.json","target-NightlyMemCheck-Release-6370ad5d8e2a852dd1ae.json","target-NightlyMemoryCheck-Debug-c395a64f6fe9ee158c25.json","target-NightlyMemoryCheck-RelWithDebInfo-a6904fd56b18e675e4de.json","target-NightlyMemoryCheck-Release-eae8779f067ddf57ff3a.json","target-NightlyStart-Debug-7c042be0317455218be2.json","target-NightlyStart-RelWithDebInfo-2049e11ae81fcb6e59de.json","target-NightlyStart-Release-5830d1fd953179bc216d.json","target-NightlySubmit-Debug-e53d0bbb1ae7a904c9c7.json","target-NightlySubmit-RelWithDebInfo-a853923e6cb63c0936b5.json","target-NightlySubmit-Release-d3abdd3462dceaec0618.json","target-NightlyTest-Debug-2f2615b8e7bce2bfffb1.json","target-NightlyTest-RelWithDebInfo-1cd9daadc4660c678f8a.json","target-NightlyTest-Release-73a7db8bcff6ba92f159.json","target-NightlyUpdate-Debug-0609d5d48d13583a10ba.json","target-NightlyUpdate-RelWithDebInfo-8a10c33a4513062f8ad2.json","target-NightlyUpdate-Release-4624d6ef68898da29a56.json","target-altsup-Debug-7e1942a68f2dd5db51b6.json","target-altsup-RelWithDebInfo-51759deca7e15eb438c8.json","target-altsup-Release-3e1a7bf6c64496c90f93.json","target-tests-Debug-c12937b26c56691dc95b.json","target-tests-RelWithDebInfo-196b90529fa97a08b772.json","target-tests-Release-69bef8b06b9bf5b289ca.json","toolchains-v1-ea743382ec2424f944f5.json"]
[extension] Not updating the configuration provider because "C_Cpp.intelliSenseEngine" is set to "Disabled"
[expand] expanding cmake
[expand] expanding cmake
[expand] expanding -T
[expand] expanding test
[expand] expanding --output-on-failure
[extension] [7442] cmake.configure finished (returned 0)

Additional Information

CMakeUserPresets.json

Metadata

Metadata

Assignees

Labels

buga bug in the product

Type

No type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions