Skip to content

cmake: skip probes for required C++ standard#2113

Open
tianrking wants to merge 1 commit into
abseil:masterfrom
tianrking:agent/skip-cxx-standard-probes
Open

cmake: skip probes for required C++ standard#2113
tianrking wants to merge 1 commit into
abseil:masterfrom
tianrking:agent/skip-cxx-standard-probes

Conversation

@tianrking

Copy link
Copy Markdown

Summary

  • Skip the C++17/C++20 compiler feature probes when the consuming project has explicitly selected and required a C++ language standard.
  • Preserve the existing probe path when no standard is selected, or when CMake is allowed to fall back to a lower standard.

Root cause

CMake/AbseilDll.cmake always ran two check_cxx_source_compiles calls, even when CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED already establish the language-mode contract for every target. This adds configuration-time compilations without changing the selected feature level.

The new branch only derives the internal feature flags from CMAKE_CXX_STANDARD when the requested standard is required. Optional standards retain compiler probing so a CMake fallback cannot be mistaken for a guaranteed language mode.

Fixes #2023.

Validation

  • Configured with -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON: 0 Abseil standard probe lines.
  • Configured with -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON: 0 Abseil standard probe lines.
  • Configured with -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=OFF: existing probes still run.
  • Built the strings CMake target with both required C++17 and required C++20 configurations on MSVC.
  • Ran git diff --check.

@tianrking
tianrking marked this pull request as ready for review July 16, 2026 04:53
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.

[Bug]: Abseil CMake try_compile calls are unnecessary

1 participant