From 7190285cbb258564decb9a3f2a3ece97fd1a92a7 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Fri, 22 Nov 2024 18:24:17 +0100 Subject: [PATCH] cmake: unbundle libpng --- CMakeLists.txt | 5 +++-- cmake/Findzlib-ng.cmake | 15 --------------- externals/CMakeLists.txt | 31 ++++++++++++++++++------------- 3 files changed, 21 insertions(+), 30 deletions(-) delete mode 100644 cmake/Findzlib-ng.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a967c540..9a8a2d12 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ find_package(fmt 10.2.0 CONFIG) find_package(glslang 14.2.0 CONFIG) find_package(half 1.12.0 MODULE) find_package(magic_enum 0.9.6 CONFIG) +find_package(PNG 1.6 MODULE) find_package(RenderDoc 1.6.0 MODULE) find_package(SDL3 3.1.2 CONFIG) find_package(toml11 4.2.0 CONFIG) @@ -121,7 +122,7 @@ find_package(VulkanHeaders 1.3.289 CONFIG) find_package(VulkanMemoryAllocator 3.1.0 CONFIG) find_package(xbyak 7.07 CONFIG) find_package(xxHash 0.8.2 MODULE) -find_package(zlib-ng 2.1.7 MODULE) +find_package(ZLIB 1.3 MODULE) find_package(Zydis 5.0.0 CONFIG) find_package(pugixml 1.14 CONFIG) @@ -830,7 +831,7 @@ endif() create_target_directory_groups(shadps4) -target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half zlib-ng::zlib png_static) +target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half ZLIB::ZLIB PNG::PNG) target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::SPIRV glslang::glslang SDL3::SDL3 pugixml::pugixml) target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h") diff --git a/cmake/Findzlib-ng.cmake b/cmake/Findzlib-ng.cmake deleted file mode 100644 index ec6f14b4..00000000 --- a/cmake/Findzlib-ng.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -find_package(PkgConfig QUIET) -pkg_search_module(ZLIB_NG QUIET IMPORTED_TARGET zlib-ng) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(zlib-ng - REQUIRED_VARS ZLIB_NG_LINK_LIBRARIES - VERSION_VAR ZLIB_NG_VERSION -) - -if (zlib-ng_FOUND AND NOT TARGET zlib-ng::zlib) - add_library(zlib-ng::zlib ALIAS PkgConfig::ZLIB_NG) -endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 8d080acc..53802276 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -52,15 +52,20 @@ file(GLOB LIBATRAC9_SOURCES LibAtrac9/C/src/*.c) add_library(LibAtrac9 STATIC ${LIBATRAC9_SOURCES}) target_include_directories(LibAtrac9 INTERFACE LibAtrac9/C/src) -# Zlib-Ng -if (NOT TARGET zlib-ng::zlib) +# zlib +if (NOT TARGET ZLIB::ZLIB) set(ZLIB_ENABLE_TESTS OFF) set(WITH_GTEST OFF) set(WITH_NEW_STRATEGIES ON) set(WITH_NATIVE_INSTRUCTIONS ON) set(ZLIB_COMPAT ON CACHE BOOL "" FORCE) - add_subdirectory(zlib-ng) - add_library(zlib-ng::zlib ALIAS zlib) + include(FetchContent) + FetchContent_Declare( + ZLIB + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng" + OVERRIDE_FIND_PACKAGE + ) + FetchContent_MakeAvailable(ZLIB) add_library(ZLIB::ZLIB ALIAS zlib) endif() @@ -156,15 +161,15 @@ if (NOT TARGET half::half) endif() # libpng -set(PNG_SHARED OFF CACHE BOOL "" FORCE) -set(PNG_STATIC ON CACHE BOOL "" FORCE) -set(PNG_TESTS OFF CACHE BOOL "" FORCE) -set(PNG_TOOLS OFF CACHE BOOL "" FORCE) -set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE) -set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib-ng" CACHE STRING "" FORCE) -set(ZLIB_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/zlib-ng/zlibstatic-ngd" CACHE STRING "" FORCE) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libpng/zlib.h" "#include \"../zlib-ng/zlib.h\"") -add_subdirectory(libpng) +if (NOT TARGET PNG::PNG) + set(PNG_SHARED OFF CACHE BOOL "" FORCE) + set(PNG_STATIC ON CACHE BOOL "" FORCE) + set(PNG_TESTS OFF CACHE BOOL "" FORCE) + set(PNG_TOOLS OFF CACHE BOOL "" FORCE) + set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE) + add_subdirectory(libpng) + add_library(PNG::PNG ALIAS png_static) +endif() if (APPLE) # date