sebastian-ne added a comment.

This breaks builds when LLVM is included with CMake’s `add_subdirectory`.
I think the zstd target needs to be marked as imported.
The following patch fixes the problem, although I’m not familiar enough with 
CMake to know if this is the right way to go:

  diff --git a/llvm/cmake/modules/FindZSTD.cmake 
b/llvm/cmake/modules/FindZSTD.cmake
  index 43ccf7232138..8e6ec6e8a988 100644
  --- a/llvm/cmake/modules/FindZSTD.cmake
  +++ b/llvm/cmake/modules/FindZSTD.cmake
  @@ -12,6 +12,10 @@ find_package_handle_standard_args(
       ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
  
   if(ZSTD_FOUND)
  +    if(NOT TARGET Zstd::zstd)
  +      add_library(Zstd::zstd UNKNOWN IMPORTED)
  +      set_target_properties(Zstd::zstd PROPERTIES IMPORTED_LOCATION 
"${ZSTD_LIBRARY}")
  +    endif()
       set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
       set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
   endif()
  diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
  index 52b95c5377d3..031adfa33ba8 100644
  --- a/llvm/lib/Support/CMakeLists.txt
  +++ b/llvm/lib/Support/CMakeLists.txt
  @@ -26,7 +26,7 @@ if(LLVM_ENABLE_ZLIB)
   endif()
  
   if(LLVM_ENABLE_ZSTD)
  -  list(APPEND imported_libs zstd)
  +  list(APPEND imported_libs Zstd::zstd)
   endif()
  
   if( MSVC OR MINGW )


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128465/new/

https://reviews.llvm.org/D128465

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to