ITADN

Setting projection-cmake-build-directory to nil breaks projection-commands-configure-project

#12Closedjobor 创建于 2024-07-02
J
joborcommented
I have a `CMakePresets.json` with a `configurePreset` that sets `binaryDir`. A simplified version looks like this: ``` { "version": 6, "configurePresets": [ { "name": "base", "hidden": true, "binaryDir": "build/${presetName}" }, { "inherits": "base", "name": "debug", "displayName": "Debug", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } } ] } ``` Now, `projection-commands-configure-project` calls `cmake -S . -B build --preset debug`, which overrides the build directory in the preset. The documentation of `projection-cmake-build-directory` suggests to set this variable to `nil`: > When unset no -B flag will be passed to CMake. You may want this if the build > directory is configured directly in the CMakePresets or elsewhere. However, configuration now fails with the following error and call stack: ``` Debugger entered--Lisp error: (wrong-type-argument stringp nil) f-absolute-p(nil) f-relative-p(nil) f-join(nil ".cmake/api/v1/query/client-emacs-projection/query....") projection-cmake--file-api-create-query-file() projection-cmake--file-api-create-query-hook(:project (vc Git "~/dev/personal/untitled666/")) projection-commands--run-command-for-type((vc Git "~/dev/personal/untitled666/") "cmake -S . --preset\\=release" configure projection-commands-pre-configure-hook projection-commands-post-configure-hook) projection-commands-configure-project((vc Git "~/dev/personal/untitled666/") "cmake -S . --preset\\=release") funcall-interactively(projection-commands-configure-project (vc Git "~/dev/personal/untitled666/") "cmake -S . --preset\\=release") command-execute(projection-commands-configure-project record) execute-extended-command(nil "projection-commands-configure-project" nil) funcall-interactively(execute-extended-command nil "projection-commands-configure-project" nil) command-execute(execute-extended-command) ``` This seems to stem from using the CMake file API, which needs to know the build directory at configure time. With CMake presets we have a chicken-egg-problem: we don't know the build directory before configuring (and besides, to know the build directory after configuring we'd have to do jump through some hoops too). The README suggests that there's a way to turn off the CMake file API usage: > Target resolution through the [CMake file API](https://cmake.org/cmake/help/v3.15/manual/cmake-file-api.7.html). This is disabled by default but can be enabled by customizing projection-cmake-target-backend (for example: (setq projection-cmake-target-backend 'code-model)) and then re-configuring the project. but the mentioned variable has been obsoleted and removed. Long story short, I suggest two changes: - update of README.org - don't use the CMake file API if projection-cmake-build-directory is nil P.S. Thanks for this very nice project! :)
关闭于 2024-07-07 4 条评论