From c21226ed94a91742449f49482e31747e3aab781f Mon Sep 17 00:00:00 2001 From: tz <185176969+tzhaoo@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:58:52 +0200 Subject: [PATCH] Reuse parent-provided ZLIB::ZLIB target When ScopeWriter is added as a subdirectory of a project that already defines ZLIB::ZLIB (for example via a static Qt build that pulls in WrapZLIB), creating the alias fails with a duplicate target error. Only alias the bundled zlibstatic when no ZLIB::ZLIB target exists. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 181a887..d40dc8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,10 @@ add_subdirectory( EXCLUDE_FROM_ALL ) unset(SKIP_INSTALL_ALL) -add_library(ZLIB::ZLIB ALIAS zlibstatic) +# A parent project may already provide ZLIB::ZLIB (e.g. via a static Qt build). +if (NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB ALIAS zlibstatic) +endif () set(CRC32C_BUILD_TESTS OFF) set(CRC32C_BUILD_BENCHMARKS OFF)