microsoft / microsoft/vscode-cmake-tools

External projects not handled as I would expect

Open
#1,616 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: other upstream
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

When my CMakeLists.txt adds an external project via the ExternalProject_add command, the added subproject is not handled as I would expect it to be. This is especially problematic for "superbuild" projects where everything is an ExternalProject.

I am quite new to the ExternalProject feature and to CMake Tools for VS Code, so it is possible that my expectations are plain wrong...

### Expected:

1. Create a project where the main CMakeLists.txt file adds a sub project using the ExternalProject_add command
2. Make both the top-level and the exernal project have a target, where the preprocessor symbol DEFINED_BY_COMPILER is defined to some value, refer to this symbol in the source files.
3. Open the directory where the main CMakeLists.txt file is located with VS Code.
4. Allow CMake tools to configure IntelliSense
5. Open a source file in the main project and the external project and be able to see the value of DEFINED_BY_COMPILER by hovering over it in both files, and don't see any squiggles
6. Be able to find the targets and their source files for both the main project and the external project in the CMake Project Outline.

### Apparent Behavior:

1. Create a project where the main CMakeLists.txt file adds a sub project using the ExternalProject_add command
2. Make both the top-level and the exernal project have a target, where the preprocessor symbol DEFINED_BY_COMPILER is defined to some value, refer to this symbol in the source files.
3. Open the directory where the main CMakeLists.txt file is located with VS Code.
4. Allow CMake tools to configure IntelliSense
5. Open a source file in the main project and the external project. Things works fine for the main project, but in the external project the hovering over DEFINED_BY_COMPILER doesn't work and an error saying 'identifier "DEFINED_BY_COMPILER" is undefined' is shown
6. The targets and related source files are shown correctly for the main project, but the external project is shown with -- Utility" appended to its name and a "build" entry below it instead of the targets.

### CMake Tools Log

[variant] Loaded new set of variants
[kit] Successfully loaded 10 kits from /home/pal/.local/share/CMakeTools/cmake-tools-kits.json
[main] Configuring folder: addexternal-repro
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/gcc-9 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/g++-9 -H/home/pal/tmp/addexternal-repro -B/home/pal/tmp/addexternal-repro/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 9.3.0
[cmake] -- The CXX compiler identification is GNU 9.3.0
[cmake] -- Check for working C compiler: /bin/gcc-9
[cmake] -- Check for working C compiler: /bin/gcc-9 -- works
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Check for working CXX compiler: /bin/g++-9
[cmake] -- Check for working CXX compiler: /bin/g++-9 -- works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[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/pal/tmp/addexternal-repro/build

### Developer Tools Log

ERR [File Watcher (node.js)] Error: ENOENT: no such file or directory, stat '/home/pal/tmp/addexternal-repro/.vscode'
abstractExtensionService.ts:840 Extension 'ms-toolsai.jupyter cannot use PROPOSED API (must started out of dev or enabled via --enable-proposed-api)
TMScopeRegistry.ts:45 Overwriting grammar scope name to file mapping for scope source.toml.
Old grammar file: file:///home/pal/.vscode/extensions/be5invis.toml-0.5.1/extension/toml.tmLanguage.json.
New grammar file: file:///home/pal/.vscode/extensions/bungcip.better-toml-0.3.2/syntaxes/TOML.tmLanguage
TMScopeRegistry.ts:45 Overwriting grammar scope name to file mapping for scope source.yaml.
Old grammar file: file:///usr/share/code/resources/app/extensions/yaml/syntaxes/yaml.tmLanguage.json.
New grammar file: file:///home/pal/.vscode/extensions/redhat.vscode-yaml-0.14.0/syntaxes/yaml.tmLanguage.json
console.ts:137 [Extension Host] activating extension
console.ts:137 [Extension Host] starting language server
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.752Z [debug] [main] Safe constructing new CMakeTools instance
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.752Z [debug] [variant] Constructing VariantManager
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.753Z [debug] [main] Constructing new CMakeTools instance
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.753Z [debug] [main] Starting CMakeTools second-phase init
console.ts:137 [Extension Host] (node:43870) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.919Z [info] [variant] Loaded new set of variants
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.920Z [debug] [main] CMakeTools instance initialization complete.
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.934Z [debug] [kit] Reading kits file /home/pal/.local/share/CMakeTools/cmake-tools-kits.json
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.968Z [info] [kit] Successfully loaded 10 kits from /home/pal/.local/share/CMakeTools/cmake-tools-kits.json
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.972Z [debug] [kit] Not reading non-existent kits file: /home/pal/tmp/addexternal-repro/.vscode/cmake-kits.json
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.972Z [debug] [main] Injecting new Kit into CMake driver
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.998Z [debug] [extension] Configuring workspace on open file:///home/pal/tmp/addexternal-repro
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.999Z [info] [main] Configuring folder: addexternal-repro
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:40:59.999Z [debug] [main] Saving open files before configure/build
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.250Z [debug] [main] Starting new CMake driver
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.251Z [debug] [main] Starting CMake driver
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.251Z [debug] [cmakefileapi-driver] Creating instance of CMakeFileApiDriver
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.252Z [debug] [driver] CMakeDriver Kit set to GCC 9.3.0
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.253Z [debug] [driver] Trying to detect generator supported by system
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.282Z [debug] [driver] Command version test return code 0
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.283Z [debug] [driver] Run _refreshExpansions
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.283Z [debug] [driver] Run _refreshExpansions cb
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.298Z [debug] [driver] Setting new variant , Disable optimizations - include debug information.
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.299Z [debug] [driver] Run _refreshExpansions
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.299Z [debug] [driver] Run _refreshExpansions cb
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.316Z [debug] [driver] Runnnig pre-configure checks and steps
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.351Z [debug] [driver] Run _refreshExpansions
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.351Z [debug] [driver] Run _refreshExpansions cb
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.353Z [debug] [driver] Start configure
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.353Z [debug] [driver] Runnnig pre-configure checks and steps
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.354Z [debug] [driver] Using compilers in GCC 9.3.0 for configure
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.354Z [debug] [driver] Run _refreshExpansions
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.355Z [debug] [driver] Run _refreshExpansions cb
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.382Z [debug] [cmakefileapi-driver] Invoking CMake /usr/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_C_COMPILER:FILEPATH=/bin/gcc-9","-DCMAKE_CXX_COMPILER:FILEPATH=/bin/g++-9","-H/home/pal/tmp/addexternal-repro","-B/home/pal/tmp/addexternal-repro/build","-G","Ninja"]
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.383Z [info] [proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/gcc-9 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/g++-9 -H/home/pal/tmp/addexternal-repro -B/home/pal/tmp/addexternal-repro/build -G Ninja
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.397Z [info] [cmake] Not searching for unused variables given on the command line.
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.459Z [info] [cmake] -- The C compiler identification is GNU 9.3.0
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.521Z [info] [cmake] -- The CXX compiler identification is GNU 9.3.0
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.527Z [info] [cmake] -- Check for working C compiler: /bin/gcc-9
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.572Z [info] [cmake] -- Check for working C compiler: /bin/gcc-9 -- works
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.573Z [info] [cmake] -- Detecting C compiler ABI info
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.613Z [info] [cmake] -- Detecting C compiler ABI info - done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.629Z [info] [cmake] -- Detecting C compile features
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.629Z [info] [cmake] -- Detecting C compile features - done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.632Z [info] [cmake] -- Check for working CXX compiler: /bin/g++-9
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.684Z [info] [cmake] -- Check for working CXX compiler: /bin/g++-9 -- works
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.685Z [info] [cmake] -- Detecting CXX compiler ABI info
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.729Z [info] [cmake] -- Detecting CXX compiler ABI info - done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.743Z [info] [cmake] -- Detecting CXX compile features
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.743Z [info] [cmake] -- Detecting CXX compile features - done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.763Z [info] [cmake] -- Configuring done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.766Z [info] [cmake] -- Generating done
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.768Z [info] [cmake] -- Build files have been written to: /home/pal/tmp/addexternal-repro/build
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.771Z [debug] [cmakefileapi-parser] Read reply folder: /home/pal/tmp/addexternal-repro/build/.cmake/api/v1/reply
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.771Z [debug] [cmakefileapi-parser] Found index files: ["cache-v2-4eaa523add7f2ed08838.json","codemodel-v2-2d8636eb431e778a164b.json","index-2021-01-13T05-41-00-0768.json","target-ExtProj-Debug-16bd909f7d7bda33e795.json","target-test_prog_1-Debug-6777f71abc829f3d0af0.json"]
2
console.ts:137 [Extension Host] Command version test return code 0
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.806Z [debug] [cache] Reading CMake cache file /home/pal/tmp/addexternal-repro/build/CMakeCache.txt
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.807Z [debug] [cache] Parsing CMake cache string
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.859Z [debug] [cache] Reading CMake cache file /home/pal/tmp/addexternal-repro/build/CMakeCache.txt
console.ts:137 [Extension Host] [CMakeTools] 2021-01-13T05:41:00.860Z [debug] [cache] Parsing CMake cache string
console.ts:137 [Extension Host] updateCustomBrowseConfiguration
2
console.ts:137 [Extension Host] provideCustomConfiguration


### Platform and Versions

- **Operating System**: Ubuntu 20.04.1
- **CMake Version**: 3.16.3
- **VSCode Version**: 1.52.1
- **CMake Tools Extension Version**: 1.5.3
- **Compiler/Toolchain**: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported ExternalProject_add setup in CMake Tools for VS Code, using the listed IntelliSense and CMake Project Outline steps. Trace how the external project is represented after configuration and compare it with the expected targets, source files, and DEFINED_BY_COMPILER behavior; done means both top-level and external projects behave as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, typescript, vscode
Domain
developer-experience, devtools, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.