Skip to content

ci: use target_compile_definitions for smart holder test define - #6289

Merged
henryiii merged 1 commit into
pybind:masterfrom
henryiii:cmake-target-compile-defs
Nov 20, 2026
Merged

henryiii merged 1 commit into
pybind:masterfrom
henryiii:cmake-target-compile-defs

Conversation

@henryiii

@henryiii henryiii commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

We should never use non-target commands in CMake.

🤖 AI text below 🤖

Description

CMake 4.5.0 gives a non-target-directive dev warning for add_compile_definitions. With -Werror=dev, this stops the configure step in the PYBIND11_TEST_SMART_HOLDER=ON jobs (example: #6288).

  • tests/test_with_catch: put the define on test_with_catch and external_module with target_compile_definitions.
  • tests/test_cmake_build: remove the define. That directory has only custom targets, and the nested builds do not receive it, so it had no effect.

Configured locally with CMake 4.5.0 and -Werror=dev, and ran cpptest with smart holder on.

CMake 4.5 warns on add_compile_definitions (non-target-directive),
which -Werror=dev makes fatal.

Assisted-by: ClaudeCode:claude-opus-5-5
@henryiii

Copy link
Copy Markdown
Collaborator Author

Fixing bad CMake usage that now warns breaking CI; going to merge.

@henryiii
henryiii merged commit c6342b4 into pybind:master Nov 20, 2026
96 checks passed
@henryiii
henryiii deleted the cmake-target-compile-defs branch November 20, 2026 20:01
@github-actions github-actions Bot added the needs changelog Possibly needs a changelog entry label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs changelog Possibly needs a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant