Open peterallin opened 3 years ago
An example that reproduces the problem is attached here:
A screenshot showing the 'identifier "DEFINED_BY_COMPILER" is undefined' error and the CMake Project Outline:
Thank you for the example project. That helped a lot!
The problem appears to be due to the fact that CMake doesn't tell us about ext/src/main.cpp
(you will also notice it does not appear in the project outline in your screenshot). I poked around in the build/.cmake/api/v1 folder where CMake dumps the code model for the projects and there is no mention of test_prog_2 or the source files needed to compile it. As a result we don't know how to send a configuration for it to cpptools and you end up with cpptools' default configuration.
This appears to be a bug with cmake-file-api. Would you be able to open a bug for it? https://gitlab.kitware.com/cmake/cmake/-/issues
@peterallin Hi Peter, did you wind up opening a bug for this issue in the CMake bug tracker? I searched for one but couldn't find anything that looked relevant. I'm working on a CMake project that is also impacted by this issue so I was wondering whether we could expect an upstream fix any time soon.
@cj-obrien sorry no. I ended up being distracted by other work. When I got back to this, we ended up using a solution without external projects.
No worries, thanks for the prompt reply :)
Bug filed against cmake-file-api: https://gitlab.kitware.com/cmake/cmake/-/issues/22759
Won't be fixed upstream, suggest closing this issue.
Now being tracked by this issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22826
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:
Apparent Behavior:
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