cmake: Switch include_directories -> target_include_directories #36889

Manually merged
hebasto merged 3 commits from 261116-non-target-directive into master 2026-11-18 15:56:08 +00:00 AGit
hebasto commented 2026-11-16 14:00:06 +00:00 (Migrated from github.com)

Use of non-target directives is not recommended. As of CMake 4.5.0, such use triggers -Wnon-target-directive warnings:

$ cmake -B build -Wnon-target-directive
<snip>
CMake Warning (non-target-directive) at src/CMakeLists.txt:8 (include_directories):
  Use of non-target directives is not recommended.  Consider
  target_include_directories instead.
This warning is for project developers.  Use -Wno-author or
-Wno-non-target-directive to suppress it.

<snip>

This PR:

  1. Links bitcoin_ipc against core_interface, so that ipc/stub.cpp is compiled with the project-wide build flags.

  2. Replaces the include_directories() call in src/CMakeLists.txt with target_include_directories().

  3. Removes the custom WarnAboutGlobalProperties module, which is superseded by the new CMake warning.


The counterpart for the secp256k1 repo is https://github.com/bitcoin-core/secp256k1/pull/1996.

Use of non-target directives is not recommended. As of CMake 4.5.0, such use triggers `-Wnon-target-directive` warnings: ```console $ cmake -B build -Wnon-target-directive <snip> CMake Warning (non-target-directive) at src/CMakeLists.txt:8 (include_directories): Use of non-target directives is not recommended. Consider target_include_directories instead. This warning is for project developers. Use -Wno-author or -Wno-non-target-directive to suppress it. <snip> ``` This PR: 1. Links `bitcoin_ipc` against `core_interface`, so that `ipc/stub.cpp` is compiled with the project-wide build flags. 2. Replaces the `include_directories()` call in `src/CMakeLists.txt` with `target_include_directories()`. 3. Removes the custom [`WarnAboutGlobalProperties`](https://github.com/bitcoin/bitcoin/blob/29f7e30d547c30ddb7a637bc3a2dbc7c0e3f5469/cmake/module/WarnAboutGlobalProperties.cmake) module, which is superseded by the new CMake warning. --- The counterpart for the `secp256k1` repo is https://github.com/bitcoin-core/secp256k1/pull/1996.
DrahtBot commented 2026-11-16 14:00:17 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK fanquake

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36889 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36889.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36889#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [fanquake](https://github.com/bitcoin/bitcoin/pull/36889#issuecomment-6983691167) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

No verified findings are available from this review.

Review coverage was incomplete.


Reviewed: 435d5b227748 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:2b20819f882b885f79f242c01722f54f2a55e27dcfa7d5e13701b4a0b5214248:c39fdacfa3b84799844a5e841c04997e3cd1142653dfad8e36dbb07c4b1e684b --> <!-- ralph-base:e211dd0186e9646167d063a16f0da88e5f72e05f --> <!-- ralph-head:435d5b227748a0ac5d6d2887050acf02304576f2 --> <!-- ralph-case:2c15a4d0dfc5dbe21f4164f7b8da7f09392f9ba7b6d4f4d3c1c897985c36e34e --> No verified findings are available from this review. Review coverage was incomplete. <!-- Review tier: standard --> --- Reviewed: [`435d5b227748`](<https://git.fish.foo/bitcoin/bitcoin/commit/435d5b227748a0ac5d6d2887050acf02304576f2>) · [Review report](<https://review.fish.foo/report/36889-435d5b227748a0ac5d6d2887050acf02304576f2-2747-3.html>) · [Previous reports](<https://review.fish.foo/traces/36889/>) [permalink](<https://review.fish.foo/report/36889-435d5b227748a0ac5d6d2887050acf02304576f2-2747-3.html>)
fanquake commented 2026-11-17 10:41:10 +00:00 (Migrated from github.com)

Our custom check does not cover the src/ subdirectory.

Can you elaborate? Does this mean it wasn't working properly?

Once one of the CI jobs runs CMake >=4.5.0, that custom check can be removed.

brew is already shipping CMake 4.5.0, so it should be in the CI any time from now, and I'd assume most macOS devs are already using it. So this could just be dropped now?

> Our custom [check](https://github.com/bitcoin/bitcoin/blob/29f7e30d547c30ddb7a637bc3a2dbc7c0e3f5469/CMakeLists.txt#L744-L745) does not cover the src/ subdirectory. Can you elaborate? Does this mean it wasn't working properly? > Once one of the CI jobs runs CMake >=4.5.0, that custom check can be removed. `brew` is already shipping CMake 4.5.0, so it should be in the CI any time from now, and I'd assume most macOS devs are already using it. So this could just be dropped now?
hebasto commented 2026-11-17 11:19:55 +00:00 (Migrated from github.com)

Our custom check does not cover the src/ subdirectory.

Can you elaborate? Does this mean it wasn't working properly?

It checks the properties of the current directory, which is the repo’s root. If I recall correctly, that was considered sufficient when the check was introduced, as all global compiler and linker flags are set there. The include_directories() call fixed in this PR is the only case it missed.

> > Our custom [check](https://github.com/bitcoin/bitcoin/blob/29f7e30d547c30ddb7a637bc3a2dbc7c0e3f5469/CMakeLists.txt#L744-L745) does not cover the src/ subdirectory. > > Can you elaborate? Does this mean it wasn't working properly? It checks the properties of the current directory, which is the repo’s root. If I recall correctly, that was considered sufficient when the check was introduced, as all global compiler and linker flags are set there. The `include_directories()` call fixed in this PR is the only case it missed.
hebasto commented 2026-11-17 11:35:31 +00:00 (Migrated from github.com)

Once one of the CI jobs runs CMake >=4.5.0, that custom check can be removed.

brew is already shipping CMake 4.5.0, so it should be in the CI any time from now, and I'd assume most macOS devs are already using it. So this could just be dropped now?

Sure. Dropped.

> > Once one of the CI jobs runs CMake >=4.5.0, that custom check can be removed. > > `brew` is already shipping CMake 4.5.0, so it should be in the CI any time from now, and I'd assume most macOS devs are already using it. So this could just be dropped now? Sure. Dropped.
fanquake commented 2026-11-18 15:51:21 +00:00 (Migrated from github.com)

ACK 435d5b2277 - going to merge this now, given it was mentioned on IRC that devs are seeing local build breakage (after updating CMake).

ACK 435d5b227748a0ac5d6d2887050acf02304576f2 - going to merge this now, given it was mentioned on IRC that devs are seeing local build breakage (after updating CMake).
fanquake commented 2026-11-18 16:07:41 +00:00 (Migrated from github.com)

Backported to 32.x in #36727.

Backported to `32.x` in #36727.
fanquake commented 2026-11-18 16:13:40 +00:00 (Migrated from github.com)

Backported to 31.x in #36901.

Backported to `31.x` in #36901.
fanquake commented 2026-11-18 16:39:13 +00:00 (Migrated from github.com)

Backported to 30.x in #36902.

Backported to `30.x` in #36902.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36889
No description provided.