Skip to content

Findzstd.cmake conflicts with CMake-generated zstd config module #139666

Open
@ziyao233

Description

@ziyao233

When importing LLVM 20.1.4 before zstd 1.5.7 (built with CMake) in CMake config mode, CMake throws strange errors,

# Example
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)

project(test LANGUAGES C CXX)

find_package(LLVM CONFIG)
find_package(zstd CONFIG)

-- The C compiler identification is Clang 20.1.4
-- The CXX compiler identification is Clang 20.1.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /lib64/cmake/zstd/zstdTargets.cmake:42 (message):
  Some (but not all) targets in this export set were already defined.

  Targets Defined: zstd::libzstd_shared

  Targets not yet defined: zstd::libzstd

Call Stack (most recent call first):
  /lib64/cmake/zstd/zstdConfig.cmake:42 (include)
  CMakeLists.txt:6 (find_package)


-- Configuring incomplete, errors occurred!

It seems llvm/cmake/modules/Findzstd.cmake defines only a subset of targets defined in zstdTargets.cmake (only zstd::libzstd_shared but not zstd::libzstd) thus messes zstd's cmake script up, which considers an incomplete importing happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cmakeBuild system in general and CMake in particular

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions