From 2880cb3bc9d8505874e670530bb0f49ac4650661 Mon Sep 17 00:00:00 2001 From: crueter Date: Wed, 27 Aug 2025 15:00:16 -0400 Subject: [PATCH] [cmake] fix zstd (force pkgconfig, thanks facebook) Signed-off-by: crueter --- CMakeLists.txt | 6 +++++- CMakeModules/CPMUtil.cmake | 2 +- CMakeModules/Findzstd.cmake | 17 ++++++----------- src/common/CMakeLists.txt | 8 +------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8292d4fd8e..185efcbd91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,6 +439,10 @@ if (YUZU_USE_CPM) # zstd AddJsonPackage(zstd) + if (zstd_ADDED) + add_library(zstd::zstd ALIS libzstd_static) + endif() + # Catch2 if (YUZU_TESTS OR DYNARMIC_TESTS) AddJsonPackage(catch2) @@ -464,7 +468,7 @@ else() find_package(enet 1.3 MODULE REQUIRED) find_package(Opus 1.3 MODULE REQUIRED) find_package(ZLIB 1.2 REQUIRED) - find_package(zstd 1.5 REQUIRED) + find_package(zstd 1.5 REQUIRED MODULE) if (YUZU_TESTS) find_package(Catch2 3.0.1 REQUIRED) diff --git a/CMakeModules/CPMUtil.cmake b/CMakeModules/CPMUtil.cmake index 7946088c67..c89eed6eb5 100644 --- a/CMakeModules/CPMUtil.cmake +++ b/CMakeModules/CPMUtil.cmake @@ -20,7 +20,7 @@ endif() option(CPMUTIL_FORCE_BUNDLED "Force bundled packages for all CPM depdendencies" ${BUNDLED_DEFAULT}) -option(CPMUTIL_DEFAULT_SYSTEM +option(CPMUTIL_FORCE_SYSTEM "Force system packages for all CPM dependencies (NOT RECOMMENDED)" OFF) cmake_minimum_required(VERSION 3.22) diff --git a/CMakeModules/Findzstd.cmake b/CMakeModules/Findzstd.cmake index ae3ea08653..bf38d20fbf 100644 --- a/CMakeModules/Findzstd.cmake +++ b/CMakeModules/Findzstd.cmake @@ -3,17 +3,12 @@ include(FindPackageHandleStandardArgs) -find_package(zstd QUIET CONFIG) -if (zstd_CONSIDERED_CONFIGS) - find_package_handle_standard_args(zstd CONFIG_MODE) -else() - find_package(PkgConfig QUIET) - pkg_search_module(ZSTD QUIET IMPORTED_TARGET libzstd) - find_package_handle_standard_args(zstd - REQUIRED_VARS ZSTD_LINK_LIBRARIES - VERSION_VAR ZSTD_VERSION - ) -endif() +find_package(PkgConfig QUIET) +pkg_search_module(ZSTD QUIET IMPORTED_TARGET libzstd) +find_package_handle_standard_args(zstd + REQUIRED_VARS ZSTD_LINK_LIBRARIES + VERSION_VAR ZSTD_VERSION +) if (zstd_FOUND AND NOT TARGET zstd::zstd) if (TARGET zstd::libzstd_shared) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index cbe1d35fc5..6173e29f45 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -272,13 +272,7 @@ if (lz4_ADDED) endif() target_link_libraries(common PUBLIC fmt::fmt stb::headers Threads::Threads) -target_link_libraries(common PRIVATE lz4::lz4 LLVM::Demangle) - -if (TARGET libzstd_static) - target_link_libraries(common PRIVATE libzstd_static) -else() - target_link_libraries(common PRIVATE zstd) -endif() +target_link_libraries(common PRIVATE lz4::lz4 LLVM::Demangle zstd::zstd) if (TARGET unordered_dense::unordered_dense) # weird quirk of system installs