Skip to content

Use pinned Ninja and MSVC recipe for CMake compile_commands.json - #15

Open
Hannia Valera (hanniavalera) wants to merge 1 commit into
microsoft:mainfrom
hanniavalera:dev/hannia/cmake-precision-recipe
Open

Use pinned Ninja and MSVC recipe for CMake compile_commands.json#15
Hannia Valera (hanniavalera) wants to merge 1 commit into
microsoft:mainfrom
hanniavalera:dev/hannia/cmake-precision-recipe

Conversation

@hanniavalera

Copy link
Copy Markdown
Contributor

Summary

Replaces the CMake section of the generate-compile-commands skill with the precision recipe: pin the Ninja generator, the MSVC compiler, and the in-tree build directory; do not force a build type; and skip the full build.

Why

The MSBuild half of this skill was tuned for reliability, but the CMake half remained a simple cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON plus a full build, which leaves four environment-dependent defaults to chance. In an offline evaluation (1,000 attempts: 5 models x 20 iterations x 5 CMake projects x 2 skill variants), the simple recipe matched a fixed reference compile_commands.json on 0.588 of attempts, while the precision recipe matched on 0.950 (three of five models perfect), at about half the tokens and a third the wall time.

What each pin fixes

  • -G Ninja: on Windows CMake defaults to a Visual Studio generator, which lays out per-configuration MSBuild files and may not emit a single compile_commands.json. In the evaluation the simple recipe used Ninja only 481 of 500 times; the 19 that did not could not match.
  • -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl: prevents CMake from selecting a g++/clang on PATH, so every entry uses MSVC.
  • -B build: the file must land where the tooling looks (build\compile_commands.json).
  • No -DCMAKE_BUILD_TYPE: forcing a type rewrites /Od /RTC1 -MDd on every entry; the reference pins none.
  • Configure once and stop: the database is written at configure time, so a full cmake --build adds time and timeout risk without changing it.

Scope

Skill-only change to the ## CMake projects section (56 insertions, 6 deletions). The MSBuild rules and the build-system selection logic are unchanged. Complements the recently merged MSBuild reliability work, bringing the CMake path to parity.

Replaces the CMake section's simple configure with the precision recipe: pin the Ninja
generator, the MSVC compiler, and the in-tree build directory; do not force a build type;
and skip the full build. In offline evaluation this raised CMake compile-database
reliability from 0.588 to 0.950 across 1,000 attempts, bringing the CMake path to parity
with the MSBuild rules, at about half the tokens and a third the wall time.
Each pin maps to a failure the simple recipe leaves open:
- -G Ninja: on Windows CMake defaults to a Visual Studio generator, which lays out
per-configuration MSBuild files and may not emit a single compile_commands.json.
- -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl: prevents CMake from selecting a g++ or
clang on PATH, so every entry uses MSVC.
- -B build: the file must land where the tooling looks.
- No -DCMAKE_BUILD_TYPE: forcing a type rewrites the optimization and runtime flags on
every entry.
- Configure once and stop: the database is written at configure time, so a full
cmake --build adds time and timeout risk without changing it.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@hanniavalera