Comprehensive guide for CMake configuration, build reliability, and project verification in the VS 2026 environment.
This skill consolidates all requirements for maintaining a reliable CMake build system in the AG_Workspace.
Rule: Always ensure CL.exe is visible via vcvars64.bat before running CMake.
NEVER run cmake directly. ALWAYS wrap:
cmd /c "call ""C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvars64.bat"" && <YOUR_CMAKE_COMMAND>"
CMakePresets.json or CMakeLists.txt.vcvars64.bat to set PATH.If "Compiler not found":
CMakeCache.txt.Objective: Prevent vcpkg rebuilds caused by compiler/toolchain hash mismatches.
Mandate: BEFORE any CMake build:
cmake --version.*Microsoft Visual Studio*Common7*IDE*CommonExtensions*Microsoft*CMake*CMake*bin*.C:\Program Files\CMake\bin, C:\Strawberry\....Remediation: If path is wrong:
Objective: Prevent ABI hash invalidation that forces full package rebuilds (10+ minutes).
Rules:
builtin-baseline commit in vcpkg.json. Do NOT let vcpkg sit at an arbitrary HEAD.git pull vcpkg unless intentionally updating dependencies. A git pull changes port recipe files, which invalidates every cached ABI hash and triggers a full source rebuild.vcpkg_installed/ during clean builds. The build workflow MUST preserve this directory.vcpkg.json minimal — only declare packages verified by #include scan.Recovery (if ABI cache is invalidated):
All CMake presets share a single vcpkg_installed directory via VCPKG_INSTALLED_DIR in CMakePresets.json. This prevents multi-GB duplication when switching between debug and release.
Context: The "StockApp" project and its dependencies (SqlLib, etc.) are strictly standardized on the MSVC Static Runtime (/MT for Release, /MTd for Debug).
Rule:
/MD configuration to persist.CMAKE_MSVC_RUNTIME_LIBRARY is set to MultiThreaded (Release) or MultiThreadedDebug (Debug).Implementation Pattern:
In CMakeLists.txt:
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
.cpp, .c) AND header files (.h, .hpp) must be explicitly listed in CMakeLists.txt.CMakeLists.txt when adding/removing/renaming files.file(GLOB ...) unless explicitly authorized, as it hides files from the build system's dependency tracker.