From 86842c6cf0ca276145fe44fe7323f2e8533820d4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 9 Oct 2026 07:05:09 -0700 Subject: [PATCH] Use fbcode_builder's FindXxhash.cmake Summary: `thrift/cmake/FindXxhash.cmake` duplicated `build/fbcode_builder/CMake/FindXxhash.cmake`, differing only in the `Xxhash::xxhash` imported target it defines. Move that target into the fbcode_builder module and remove thrift's copy. fbthrift now installs the fbcode_builder module next to `FBThriftConfig.cmake`, as it already does for `FindGflags`, `FindGlog` and `FindLibUnwind`. The only other user of the fbcode_builder module, cachelib, reads `Xxhash_LIBRARY` and doesn't define `Xxhash::xxhash` itself, so the new target can't collide with it. Reviewed By: createdbysk Differential Revision: D123971195 fbshipit-source-id: 18474a61011d23d7374c04208b18febaee0ed1af --- build/fbcode_builder/CMake/FindXxhash.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build/fbcode_builder/CMake/FindXxhash.cmake b/build/fbcode_builder/CMake/FindXxhash.cmake index 04760cbf7..49c4c7dbe 100644 --- a/build/fbcode_builder/CMake/FindXxhash.cmake +++ b/build/fbcode_builder/CMake/FindXxhash.cmake @@ -18,6 +18,7 @@ # Xxhash_FOUND # Xxhash_INCLUDE_DIR # Xxhash_LIBRARY +# Xxhash::xxhash (imported target) # find_path(Xxhash_INCLUDE_DIR NAMES xxhash.h) @@ -37,4 +38,13 @@ if (Xxhash_FOUND) message(STATUS "Found xxhash: ${Xxhash_LIBRARY}") endif() +if (Xxhash_FOUND AND NOT TARGET Xxhash::xxhash) + add_library(Xxhash::xxhash UNKNOWN IMPORTED) + set_target_properties( + Xxhash::xxhash + PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${Xxhash_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Xxhash_INCLUDE_DIR}") +endif() + mark_as_advanced(Xxhash_INCLUDE_DIR Xxhash_LIBRARY)