Skip to content

abseil: disable CMAKE_INCLUDE_CURRENT_DIR for the in-tree build#900

Merged
jcelerier merged 1 commit into
masterfrom
fix-abseil-time-h-shadow
Jun 21, 2026
Merged

abseil: disable CMAKE_INCLUDE_CURRENT_DIR for the in-tree build#900
jcelerier merged 1 commit into
masterfrom
fix-abseil-time-h-shadow

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Problem

Building a consumer that enables CMAKE_INCLUDE_CURRENT_DIR (e.g. ossia score, which sets it globally) fails when compiling the in-tree Abseil with:

.../include/c++/14/ctime:60:11: error: no member named 'clock_t' in the global namespace; did you mean '__clock_t'?
   60 |   using ::clock_t;

Root cause

CMAKE_INCLUDE_CURRENT_DIR ON makes CMake add every target's own source/binary dir as a plain -I. For Abseil's absl/time target this injects:

-I.../abseil-cpp/absl/time

That directory contains a header literally named time.h (absl::Time). Being a plain -I, it sits ahead of /usr/include, so when a system header does #include <time.h> (e.g. pthread.h), the compiler resolves it to Abseil's absl/time/time.h instead of the C <time.h>. The C global-namespace symbols (::clock_t, ::clock, …) are then never declared, and <ctime>'s using ::clock_t; fails.

Fix

Set CMAKE_INCLUDE_CURRENT_DIR OFF inside the existing block() scope in cmake/deps/abseil.cmake, so it applies only to the Abseil subtree. Abseil includes its own headers as absl/... (via the -isystem root) and does not rely on this setting, so the change is safe and scoped.

🤖 Generated with Claude Code

A consumer (e.g. ossia score) that enables CMAKE_INCLUDE_CURRENT_DIR
makes CMake add each target's own source/binary dir as a plain -I.
For Abseil's absl/time target this injects -I.../absl/time, whose
time.h then shadows the system C <time.h> (reached e.g. via
pthread.h's #include <time.h>). The build then fails with:

  error: no member named 'clock_t' in the global namespace

Abseil includes its own headers as absl/... and does not rely on
CMAKE_INCLUDE_CURRENT_DIR, so disabling it inside the existing block()
scope is safe and limited to the Abseil subtree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017UXxiAmZEiEqjGUJhXkCpX
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier temporarily deployed to Apple Certificate June 21, 2026 11:16 — with GitHub Actions Inactive
@jcelerier jcelerier merged commit aae91ac into master Jun 21, 2026
46 checks 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