Add the CODEGEN keyword to codegen-style add_custom_command() calls - #31
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR's purpose — add the
CODEGENkeyword to codegen-styleadd_custom_command()calls so consumers on CMake 3.31+ can build the builtincodegentarget to generate resources without compiling them (ideal for clang-tidy CI) — was applied unchanged; only the diff granularity was adapted to the current3.0.0file structure:if(POLICY CMP0171) / cmake_policy(SET CMP0171 NEW)— exactly the PR's guarded block. With ourcmake_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.cmrc_add_resource_library()(line 143–149):set(maybe_CODEGEN CODEGEN)/else()empty, appended as${maybe_CODEGEN}to the resource-loaderadd_custom_command(OUTPUT "${libcpp}"...)._cmrc_generate_intermediate_cpp()(line 285–290): same pattern, appended to the intermediate-fileadd_custom_command(OUTPUT "${outfile}"...).Verification (local CMake 4.3.2, Ninja generator)
tests/— no warnings/errors.--target codegenbuilds successfully.build_codegenscratch dir,codegenproduced all 27 generated.cppfiles (every resource loader + intermediate file) with zero.objfiles and no project executables — generation without compilation, exactly the PR's goal.ctest --test-dir build --output-on-failuresuite 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.