Skip to content

Add the CODEGEN keyword to codegen-style add_custom_command() calls - #31

Merged
Randalphwa merged 1 commit into
mainfrom
CODEGEN
Sep 7, 2026
Merged

Add the CODEGEN keyword to codegen-style add_custom_command() calls#31
Randalphwa merged 1 commit into
mainfrom
CODEGEN

Conversation

@Randalphwa

@Randalphwa Randalphwa commented Sep 7, 2026

Copy link
Copy Markdown
Member

The PR's purpose — add the CODEGEN keyword to codegen-style add_custom_command() calls so consumers on CMake 3.31+ can build the builtin codegen target to generate resources without compiling them (ideal for clang-tidy CI) — was applied unchanged; only the diff granularity was adapted to the current 3.0.0 file structure:

  1. Module top (line 40–50): if(POLICY CMP0171) / cmake_policy(SET CMP0171 NEW) — exactly the PR's guarded block. With our cmake_minimum_required(VERSION 3.12...4.0) ceiling, CMP0171 auto-activates NEW on CMake 3.31+ anyway, but the block covers consumers whose own project sets an older policy version. It's a no-op on CMake < 3.31, so the 3.12 minimum constraint is preserved.
  2. cmrc_add_resource_library() (line 143–149): set(maybe_CODEGEN CODEGEN) / else() empty, appended as ${maybe_CODEGEN} to the resource-loader add_custom_command(OUTPUT "${libcpp}"...).
  3. _cmrc_generate_intermediate_cpp() (line 285–290): same pattern, appended to the intermediate-file add_custom_command(OUTPUT "${outfile}"...).

Verification (local CMake 4.3.2, Ninja generator)

  • Configured tests/ — no warnings/errors.
  • --target codegen builds successfully.
  • Proven behavior: in a fresh build_codegen scratch dir, codegen produced all 27 generated .cpp files (every resource loader + intermediate file) with zero .obj files and no project executables — generation without compilation, exactly the PR's goal.
  • Full ctest --test-dir build --output-on-failure suite passes (all tests green), confirming no regression in the normal build path.

Credit goes to @craigscott-crascit for the original idea -- I didn't use his commit exactly, since I had already changed CMakeRC, but the idea was valuable and worth doing.

@Randalphwa Randalphwa changed the title add the CODEGEN keyword to codegen-style add_custom_command() calls Add the CODEGEN keyword to codegen-style add_custom_command() calls Sep 7, 2026
@Randalphwa
Randalphwa merged commit 643f0a8 into main Sep 7, 2026
1 check passed
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.

1 participant