What Are the Dependencies of Abseil C++? Essential Build Requirements Explained

Abseil C++ requires only CMake 3.16 or newer, a C++17-compliant compiler, and the system's thread library to build; optional testing features depend solely on GoogleTest.

Abseil C++ is a header-only (with optional compiled parts) collection of utilities from Google that builds on the C++17 language standard. When integrating the abseil/abseil-cpp repository into your project, understanding its minimal dependency footprint ensures you link no unnecessary third-party runtime libraries. The following guide breaks down every build requirement as declared in the source code.

Core Build Dependencies

CMake 3.16 or Newer

The Abseil C++ library uses CMake as its primary build system generator. In the top-level CMakeLists.txt, the project declares a minimum required version of 3.16 to access modern CMake features such as cxx_std_17.

cmake_minimum_required(VERSION 3.16)

According to the source code at line 19 of CMakeLists.txt, this version requirement is mandatory.

C++17 Standard Library

All Abseil code is written for C++17, with some components optionally utilizing C++20 features. The build system enforces this via the ABSL_PROPAGATE_CXX_STD option defined in CMakeLists.txt (lines 48-50), which ensures the C++ standard propagates correctly to dependent targets.

System Thread Library

Abseil's synchronization primitives—including absl::Mutex and absl::ConditionVariable—require threading support. In CMakeLists.txt (lines 96-99), the build system explicitly searches for and requires the platform's thread library:

find_package(Threads REQUIRED)

On Unix systems, this typically resolves to POSIX pthread, while Windows targets use native Windows threads.

Optional Dependencies

GoogleTest for Development and Testing

GoogleTest is only required when building Abseil's own test suite or the test-helper libraries. This dependency is controlled via the ABSL_BUILD_TESTING and ABSL_BUILD_TEST_HELPERS CMake options. When enabled, CMakeLists.txt (lines 137-140) invokes:

find_package(GTest REQUIRED)

The repository includes CMake/Googletest/DownloadGTest.cmake to automatically fetch GoogleTest when ABSL_USE_EXTERNAL_GOOGLETEST is set to OFF.

Build System Configuration

Configuring Abseil with CMake

When integrating Abseil as a subdirectory, the CMakeLists.txt automatically handles the thread dependency resolution.


# CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(my_app LANGUAGES CXX)

# Pull in Abseil (assumes the repository is a subdirectory)

add_subdirectory(abseil-cpp)

add_executable(my_app main.cc)
target_link_libraries(my_app PRIVATE absl::base absl::strings absl::time)

The add_subdirectory(abseil-cpp) call triggers the logic in abseil-cpp/CMakeLists.txt which automatically pulls in the Threads dependency.

Configuring Abseil with Bazel

Bazel is the alternative, officially-supported build system. Dependencies are managed internally by Bazel's repository rules defined in BUILD.bazel.


# BUILD

cc_binary(
    name = "my_app",
    srcs = ["main.cc"],
    deps = [
        "@abseil//absl/base",
        "@abseil//absl/strings",
        "@abseil//absl/time",
    ],
)

Bazel fetches the Abseil repository as an external dependency (@abseil).

Enabling Test Helpers

To build with the optional testing utilities:


# Enable testing and import GoogleTest

set(ABSL_BUILD_TESTING ON)
set(ABSL_BUILD_TEST_HELPERS ON)
set(ABSL_USE_EXTERNAL_GOOGLETEST OFF)   # let Abseil download GTest

add_subdirectory(abseil-cpp)

# Build a test that uses the helper library

add_executable(my_test test.cc)
target_link_libraries(my_test PRIVATE absl::test_helper GTest::gtest_main)

When ABSL_BUILD_TEST_HELPERS is ON, the script in CMake/Googletest/DownloadGTest.cmake handles the GoogleTest acquisition.

Summary

  • Abseil C++ maintains a minimal dependency footprint, requiring only standard tooling.
  • CMake 3.16+, a C++17 compiler, and the system thread library are mandatory for all builds.
  • GoogleTest is only required when building tests or test helpers, and can be downloaded automatically.
  • Bazel users rely on the BUILD.bazel rules rather than CMake for dependency management.
  • No third-party runtime libraries are linked unless you explicitly enable optional testing facilities.

Frequently Asked Questions

Does Abseil C++ require Boost?

No. Abseil C++ is designed to depend exclusively on the C++ standard library and the system thread library. It does not link against Boost or any other third-party runtime libraries unless you explicitly enable optional testing features.

Is threading support mandatory for Abseil C++?

Yes. The find_package(Threads REQUIRED) directive in CMakeLists.txt makes threading support mandatory. Core components like absl::Mutex and absl::ConditionVariable require the system thread library (POSIX pthread on Unix, native Windows threads on Windows).

How do I enable testing dependencies in Abseil C++?

Set the CMake options ABSL_BUILD_TESTING=ON and ABSL_BUILD_TEST_HELPERS=ON. If ABSL_USE_EXTERNAL_GOOGLETEST is OFF, Abseil will use CMake/Googletest/DownloadGTest.cmake to automatically fetch GoogleTest. If set to ON, you must provide an external GoogleTest installation.

What is the minimum C++ standard required for Abseil C++?

Abseil requires C++17 at minimum. While specific compiler version minimums vary by platform, any compiler fully supporting the C++17 standard will work. Some optional features may utilize C++20 if available.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →