abseil: disable CMAKE_INCLUDE_CURRENT_DIR for the in-tree build#900
Merged
Conversation
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
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.
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:Root cause
CMAKE_INCLUDE_CURRENT_DIR ONmakes CMake add every target's own source/binary dir as a plain-I. For Abseil'sabsl/timetarget this injects: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'sabsl/time/time.hinstead of the C<time.h>. The C global-namespace symbols (::clock_t,::clock, …) are then never declared, and<ctime>'susing ::clock_t;fails.Fix
Set
CMAKE_INCLUDE_CURRENT_DIR OFFinside the existingblock()scope incmake/deps/abseil.cmake, so it applies only to the Abseil subtree. Abseil includes its own headers asabsl/...(via the-isystemroot) and does not rely on this setting, so the change is safe and scoped.🤖 Generated with Claude Code