microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 449 forks source link

Multiple project roots not configured when one root is a subdirectory of the other #3714

Open harrymander opened 5 months ago

harrymander commented 5 months ago

Brief Issue Summary

When there are two paths in sourceDirectory, and one of them is a subdirectory of the other, only the higher-level project root is configured by CMake Tools. An example repo is here for reproduction: https://github.com/harrymander/vscode-cmake-tools-nested-roots

.
├── CMakeLists.txt # calls cmake `project` command, does not add `nested` directory
├── main.cpp
└── nested
    ├── CMakeLists.txt  # calls cmake `project` command
    └── main-nested.cpp

I have the following in my settings.json:

"cmake.sourceDirectory": ["${workspaceFolder}", "${workspaceFolder}/nested"]

However, only the top-level project is configured by CMake Tools. When I open nested/CMakeLists.txt and run CMake: Configure from the command palette, it just configures the top-level project, creating a build directory under ${workspaceFolder}/build, when I would expect it to configure a new CMake root under ${workspaceFolder}/nested/build.

The problem is not present if I move the cross-compiling cmake project to a subdirectory.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.88.1",
  "cmtVersion": "1.17.17",
  "configurations": [
    {
      "folder": "/home/harry/scratch/vscode-cmake-tools-nested-roots",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    },
    {
      "folder": "/home/harry/scratch/vscode-cmake-tools-nested-roots/nested",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[expand] expanding cmake
[main] Configuring project: vscode-cmake-tools-nested-roots 
[main] Saving open files before configure/build
[expand] expanding /home/harry/scratch/vscode-cmake-tools-nested-roots
[expand] expanding ${sourceDirectory}/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[driver] Using compilers in GCC 11.3.0 x86_64-linux-gnu for configure
[expand] expanding --no-warn-unused-cli
[expand] expanding -DCMAKE_BUILD_TYPE:STRING=Debug
[expand] expanding -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE
[expand] expanding -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc
[expand] expanding -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++
[expand] expanding /home/harry/scratch/vscode-cmake-tools-nested-roots
[expand] expanding ${sourceDirectory}/build
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake /usr/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc","-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++","-S/home/harry/scratch/vscode-cmake-tools-nested-roots","-B/home/harry/scratch/vscode-cmake-tools-nested-roots/build","-G","Ninja"]
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ -S/home/harry/scratch/vscode-cmake-tools-nested-roots -B/home/harry/scratch/vscode-cmake-tools-nested-roots/build -G Ninja
[proc]   with environment: {"BASH_PROMPT_SHOW_GIT":"1","CHROME_DESKTOP":"code-url-handler.desktop","COLORTERM":"truecolor","CONDA_EXE":"/home/harry/miniconda3/bin/conda","CONDA_PYTHON_EXE":"/home/harry/miniconda3/bin/python","CONDA_SHLVL":"0","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","DEFAULTS_PATH":"/usr/share/gconf/ubuntu.default.path","DESKTOP_SESSION":"ubuntu","DISPLAY":":1","EDITOR":"vim","ELECTRON_NO_ATTACH_CONSOLE":"1","FLYCTL_INSTALL":"/home/harry/.fly","GDK_BACKEND":"x11","GDMSESSION":"ubuntu","GIO_LAUNCHED_DESKTOP_FILE_PID":"1433926","GL_HOST":"eng-git.canterbury.ac.nz","GNOME_DESKTOP_SESSION_ID":"this-is-deprecated","GNOME_SHELL_SESSION_MODE":"ubuntu","GPG_AGENT_INFO":"/run/user/1000/gnupg/S.gpg-agent:0:1","GTK_IM_MODULE":"ibus","GTK_MODULES":"gail:atk-bridge","HOME":"/home/harry","IBUS_DISABLE_SNOOPER":"1","IM_CONFIG_PHASE":"1","INVOCATION_ID":"b9247279c9bd454b9df4f39c1f59d741","JOURNAL_STREAM":"8:34627","LANG":"en_NZ.UTF-8","LANGUAGE":"en_NZ:en","LESSCLOSE":"/usr/bin/lesspipe %s %s","LESSOPEN":"| /usr/bin/lesspipe %s","LOGNAME":"harry","LS_COLORS":"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:","MANAGERPID":"2682","MANDATORY_PATH":"/usr/share/gconf/ubuntu.mandatory.path","MY_ENGGIT_SSH":"git@eng-git.canterbury.ac.nz:hma199","MY_GITHUB_SSH":"git@github.com:harrymander","NVM_BIN":"/home/harry/.nvm/versions/node/v21.6.2/bin","NVM_DIR":"/home/harry/.nvm","NVM_INC":"/home/harry/.nvm/versions/node/v21.6.2/include/node","OLDPWD":"/home/harry/scratch/vscode-cmake-tools-nested-roots/nested","ORIGINAL_XDG_CURRENT_DESKTOP":"ubuntu:GNOME","PATH":"/home/harry/.gem/ruby/3.0.0/bin:/home/harry/miniconda3/condabin:/home/harry/.fly/bin:/home/harry/.local/bin:/home/harry/go/bin:/home/harry/.cargo/bin:/home/harry/.nvm/versions/node/v21.6.2/bin:/home/harry/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/harry/.fzf/bin","PWD":"/home/harry/scratch/vscode-cmake-tools-nested-roots","QT_ACCESSIBILITY":"1","QT_IM_MODULE":"ibus","SESSION_MANAGER":"local/C032DU:@/tmp/.ICE-unix/3116,unix/C032DU:/tmp/.ICE-unix/3116","SHELL":"/bin/bash","SHLVL":"1","SSH_AGENT_LAUNCHER":"gnome-keyring","SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","SYSTEMD_EXEC_PID":"3312","TERM":"xterm-256color","TERMINATOR_DBUS_NAME":"net.tenshu.Terminator23558193cd9818af7fe4d2c2f5bd9d00f","TERMINATOR_DBUS_PATH":"/net/tenshu/Terminator2","TERMINATOR_UUID":"urn:uuid:004e2020-079a-494d-8fab-84968befedad","USER":"harry","USERNAME":"harry","VIRTUALENVWRAPPER_HOOK_DIR":"/home/harry/.virtualenvs","VIRTUALENVWRAPPER_PROJECT_FILENAME":".project","VIRTUALENVWRAPPER_PYTHON":"/usr/bin/python3","VIRTUALENVWRAPPER_SCRIPT":"/home/harry/.local/bin/virtualenvwrapper.sh","VIRTUALENVWRAPPER_WORKON_CD":"1","VISUAL":"vim","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CLI":"1","VSCODE_CODE_CACHE_PATH":"/home/harry/.config/Code/CachedData/e170252f762678dec6ca2cc69aba1570769a5d39","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/home/harry/scratch/vscode-cmake-tools-nested-roots","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/run/user/1000/vscode-22d88909-1.88-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-gb\",\"osLocale\":\"en-nz\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"1532719","VTE_VERSION":"6800","WINDOWPATH":"2","WORKON_HOME":"/home/harry/.virtualenvs","XAUTHORITY":"/run/user/1000/gdm/Xauthority","XDG_CONFIG_DIRS":"/etc/xdg/xdg-ubuntu:/etc/xdg","XDG_CURRENT_DESKTOP":"Unity","XDG_DATA_DIRS":"/usr/share/ubuntu:/usr/share/gnome:/home/harry/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop","XDG_MENU_PREFIX":"gnome-","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_CLASS":"user","XDG_SESSION_DESKTOP":"ubuntu","XDG_SESSION_TYPE":"x11","XMODIFIERS":"@im=ibus","_":"/usr/bin/code","ELECTRON_RUN_AS_NODE":"1","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The CXX compiler identification is GNU 11.4.0
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/g++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/harry/scratch/vscode-cmake-tools-nested-roots/build
[cmakefileapi-parser] Read reply folder: /home/harry/scratch/vscode-cmake-tools-nested-roots/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-d48585cc9578518c162f.json","cmakeFiles-v1-bc10beb90439ca5d24af.json","codemodel-v2-f231b8cc75d3d7843591.json","directory-.-Debug-f5ebdc15457944623624.json","index-2024-04-21T02-04-55-0449.json","target-main-Debug-19b5de53e7aaa2ef28f9.json","toolchains-v1-a2904c2398fb9530b017.json"]
[expand] expanding cmake
[extension] [6414] cmake.configure finished (returned 0)
[expand] expanding cmake
[cache] Reading CMake cache file /home/harry/scratch/vscode-cmake-tools-nested-roots/build/CMakeCache.txt
[cache] Parsing CMake cache string
[expand] expanding cmake

Additional Information

No response

harrymander commented 5 months ago

Have updated with a simpler reproducible example

Evelyn-001 commented 5 months ago

@harrymander, thanks for providing the demo project. Today we try to repro this this issue with below steps: Could you please help check the below picture if it describes your issue? If not, could you please provide a video about repro steps to us? If we miss or misunderstand anything, please let us know. Thanks. System info: Ubuntu 22.04.4 LTS

VS code version: 1.88.1

CMake Extension version: v 1.17.17& v 1.88.30 pre-release

Repro steps: 1.Open the project folder with VSCode.

  1. Run "delete cache and reconfigure" command to configure project.
  2. Observe the output System info: Ubuntu 22.04.4 LTS

VS code version: 1.88.1

CMake Extension version: v 1.17.17& v 1.88.29 pre-release

Repro steps: 1.Open the project folder with VSCode.

  1. Run "delete cache and reconfigure" command to configure project.
  2. Observe the output

Actual Results: configure a new CMake root under ${workspaceFolder}/build image

harrymander commented 5 months ago

@Evelyn-001 Yes that is the observed behaviour. Build files are always written to a build directory in the top-level project directory, even if configuring inside the nested directory (when I would expected a directory to be created at nested/build).

Not sure what you mean by "install Node using the method the customer mentioned".

Evelyn-001 commented 5 months ago

@harrymander, Sorry, please ignore this sentence. Now that we have reproduced your issue, we will continue to investigate the issue. We will get back to you if there are any updates. Thanks for your support.