Skip to content

Dependency Mappings

When migrating from CMake, rebaze needs to know how to translate CMake dependencies to Bazel targets.

CMake projects reference dependencies in several ways:

CMake PatternExampleMapping Section
-l flag-lz, -lsslsystem_libraries
Plain namegtest, boostplain_libraries
Package::ComponentOpenSSL::SSLpackages
Implicitpthread, mimplicit_system_libs

Map -l flags to Bazel targets:

[mappings.system_libraries]
z = "@zlib"
zlib = "@zlib"
ssl = "@openssl//:ssl"
crypto = "@openssl//:crypto"
curl = "@curl"

Map plain library names (without -l or ::):

[mappings.plain_libraries]
gtest = "@googletest//:gtest"
gtest_main = "@googletest//:gtest_main"
gmock = "@googletest//:gmock"
benchmark = "@google_benchmark//:benchmark"

Map find_package() targets using patterns:

[mappings.packages.Boost]
target_pattern = "@boost//:{component}"
[mappings.packages.Boost.components]
filesystem = "@boost//:filesystem"
system = "@boost//:system"

The {component} placeholder is replaced with the actual component name.

[mappings.packages.OpenSSL]
target_pattern = "@openssl//:{component}"
[mappings.packages.OpenSSL.components]
SSL = "@openssl//:ssl"
Crypto = "@openssl//:crypto"

Maps:

  • OpenSSL::SSL@openssl//:ssl
  • OpenSSL::Crypto@openssl//:crypto

Libraries provided by the system:

[mappings]
implicit_system_libs = ["pthread", "c", "m", "dl", "rt"]

These are silently ignored during migration.

Libraries to skip completely:

[mappings]
ignored_libraries = ["fmt", "spdlog", "Threads::Threads"]

Define dependencies that should be pulled in transitively:

[mappings.transitive_deps]
glib = ["pcre2", "libffi", "zlib"]
curl = ["zlib", "openssl"]

When resolving a dependency:

  1. ignored_libraries - Skip if listed
  2. implicit_system_libs - Skip if listed
  3. -l prefix → system_libraries
  4. :: separator → packages
  5. Plain name → plain_libraries
  6. Default → Warning, dependency skipped