From 59d3d282b071231a24b89af272f61aac140b10d4 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 17 Mar 2026 12:53:00 -0700 Subject: [PATCH] Fixes for CMake integration. CMAKE_SOURCE_DIR and CMAKE_CURRENT_SOURCE_DIR are different in meaningful ways in practice. Fix an issue with profile_dir where it incorrectly assumed it would always be one path component. PiperOrigin-RevId: 885164196 --- CMakeLists.txt | 2 +- cc_bindings_from_rs/cargo-cpp_api_from_rust.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be6d1d1cf..7358b89c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ FetchContent_Declare( FetchContent_MakeAvailable(absl) -include_directories(${CMAKE_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CRUBIT_SUBDIRS support diff --git a/cc_bindings_from_rs/cargo-cpp_api_from_rust.rs b/cc_bindings_from_rs/cargo-cpp_api_from_rust.rs index 5a07ff17a..1280581f3 100644 --- a/cc_bindings_from_rs/cargo-cpp_api_from_rust.rs +++ b/cc_bindings_from_rs/cargo-cpp_api_from_rust.rs @@ -137,8 +137,9 @@ fn main() -> Result<()> { profile_dir = filename .strip_prefix(&target_dir) .ok() - .and_then(|path| path.components().next()) - .map(|component| component.as_str().to_owned()); + // Remove the filename from the path. + .and_then(|path| path.parent()) + .map(|path| path.to_owned()); source_crate_rlib = artifact .filenames .iter()