Skip to content

Switch to CMake built-in precompiled headers (resolve #657)#659

Merged
nealkruis merged 1 commit into
mainfrom
resolve-pch
Jul 9, 2026
Merged

Switch to CMake built-in precompiled headers (resolve #657)#659
nealkruis merged 1 commit into
mainfrom
resolve-pch

Conversation

@tanaya-mankad

@tanaya-mankad tanaya-mankad commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Resolves #657. I believe my desktop builds now work the way you intended. This fix rewrites the PCH macro in modern CMake.

  • Replace the manual MSVC-only /Yc + /Yu StdAfx.cpp scheme with CMake's built-in target_precompile_headers(), which is generator- and compiler-agnostic (Ninja, MSBuild, GCC/Clang).

Background

The built-in support force-includes cnglob.h into every translation unit in addition to each source's own #include "cnglob.h". Because cnglob.h lacked an include guard, this double inclusion caused many redefinition errors. The old /Yu"cnglob.h" scheme masked this because MSVC discards all source text up to and including the #include "cnglob.h" line, so the header was only processed once.

Changes

  • CMakeLists.txt: require CMake >= 3.16 for target_precompile_headers()
  • src/CMakeLists.txt: drop the addMSVCPrecompiledHeader macro and StdAfx.cpp precomp entry; add target_precompile_headers(CSE PRIVATE "cnglob.h")
  • src/cnglob.h: add an #ifndef GLOB include guard (the symbol the file's own comment already anticipated) to make the header idempotent
  • src/stdafx.cpp: remove (no longer needed)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tanaya-mankad tanaya-mankad requested a review from chipbarnaby July 9, 2026 00:14
@tanaya-mankad tanaya-mankad marked this pull request as draft July 9, 2026 00:15
@tanaya-mankad tanaya-mankad marked this pull request as ready for review July 9, 2026 00:31

@chipbarnaby chipbarnaby left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for the DEBUG<->RELEASE flip back and forth use case.

@nealkruis

Copy link
Copy Markdown
Contributor

Also addresses #330.

@nealkruis nealkruis merged commit 6c1f03b into main Jul 9, 2026
3 checks passed
@nealkruis nealkruis deleted the resolve-pch branch July 9, 2026 16:31
Sign up for free to 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.

MSVC build damaged by recent CMAKE changes (or something else?)

3 participants