diff --git a/.github/workflows/scripts/linux/generate-cmake-qt.sh b/.github/workflows/scripts/linux/generate-cmake-qt.sh index 2329d15b86..3ca4a6f08e 100755 --- a/.github/workflows/scripts/linux/generate-cmake-qt.sh +++ b/.github/workflows/scripts/linux/generate-cmake-qt.sh @@ -38,13 +38,9 @@ cmake \ $ADDITIONAL_CMAKE_ARGS \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_BUILD_TYPE=Release \ - -DQT_BUILD=ON \ - -DCUBEB_API=ON \ -DX11_API=ON \ -DWAYLAND_API=ON \ -DENABLE_SETCAP=OFF \ -DCMAKE_PREFIX_PATH="${DEPS_PREFIX}" \ - -DUSE_SYSTEM_SDL2=ON \ - -DUSE_SYSTEM_ZSTD=OFF \ -DDISABLE_ADVANCE_SIMD=TRUE diff --git a/.github/workflows/scripts/linux/install-packages-qt.sh b/.github/workflows/scripts/linux/install-packages-qt.sh index 276b80da67..04a44852af 100755 --- a/.github/workflows/scripts/linux/install-packages-qt.sh +++ b/.github/workflows/scripts/linux/install-packages-qt.sh @@ -19,9 +19,11 @@ declare -a BUILD_PACKAGES=( "libfontconfig1-dev" "libharfbuzz-dev" "libjpeg-dev" + "liblz4-dev" "libpng-dev" "libfreetype-dev" "libinput-dev" + "libwebp-dev" "libxcb-*-dev" "libxkbcommon-dev" "libxkbcommon-x11-dev" diff --git a/cmake/CheckLib.cmake b/cmake/CheckLib.cmake index fceaaa0fce..27824a8550 100644 --- a/cmake/CheckLib.cmake +++ b/cmake/CheckLib.cmake @@ -7,7 +7,7 @@ endmacro() macro(check_lib var lib) set(_arg_list ${ARGN}) - if(PKG_CONFIG_FOUND AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED pcsx2_manually_found_${var}) + if(PKG_CONFIG_FOUND AND NOT DEFINED pcsx2_manually_found_${var}) string(TOLOWER ${lib} lower_lib) pkg_search_module(${var} QUIET IMPORTED_TARGET ${lower_lib}) endif() diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake new file mode 100644 index 0000000000..873de4b45e --- /dev/null +++ b/cmake/FindLZ4.cmake @@ -0,0 +1,45 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Finds liblz4. +# +# This module defines: +# LZ4_FOUND +# LZ4_INCLUDE_DIR +# LZ4_LIBRARY +# + +find_path(LZ4_INCLUDE_DIR NAMES lz4.h) + +find_library(LZ4_LIBRARY_DEBUG NAMES lz4d) +find_library(LZ4_LIBRARY_RELEASE NAMES lz4) + +include(SelectLibraryConfigurations) +SELECT_LIBRARY_CONFIGURATIONS(LZ4) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LZ4 DEFAULT_MSG + LZ4_LIBRARY LZ4_INCLUDE_DIR +) + +mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY) + +if(LZ4_FOUND AND NOT (TARGET LZ4::LZ4)) + add_library (LZ4::LZ4 UNKNOWN IMPORTED) + set_target_properties(LZ4::LZ4 + PROPERTIES + IMPORTED_LOCATION ${LZ4_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIR}) +endif() diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake new file mode 100644 index 0000000000..688419eb8d --- /dev/null +++ b/cmake/FindWebP.cmake @@ -0,0 +1,166 @@ +# Copyright (C) 2020 Sony Interactive Entertainment Inc. +# Copyright (C) 2012 Raphael Kubo da Costa +# Copyright (C) 2013 Igalia S.L. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +FindWebP +-------------- + +Find WebP headers and libraries. + +Imported Targets +^^^^^^^^^^^^^^^^ + +``WebP::libwebp`` + The WebP library, if found. + +``WebP::demux`` + The WebP demux library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables in your project: + +``WebP_FOUND`` + true if (the requested version of) WebP is available. +``WebP_VERSION`` + the version of WebP. +``WebP_LIBRARIES`` + the libraries to link against to use WebP. +``WebP_INCLUDE_DIRS`` + where to find the WebP headers. +``WebP_COMPILE_OPTIONS`` + this should be passed to target_compile_options(), if the + target is not used for linking + +#]=======================================================================] + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_WEBP QUIET libwebp) +set(WebP_COMPILE_OPTIONS ${PC_WEBP_CFLAGS_OTHER}) +set(WebP_VERSION ${PC_WEBP_CFLAGS_VERSION}) + +find_path(WebP_INCLUDE_DIR + NAMES webp/decode.h + HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS} +) + +find_library(WebP_LIBRARY + NAMES ${WebP_NAMES} webp libwebp + HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} +) + +# There's nothing in the WebP headers that could be used to detect the exact +# WebP version being used so don't attempt to do so. A version can only be found +# through pkg-config +if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") + if (WebP_VERSION) + message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${WebP_VERSION} ")") + else () + message(WARNING "Cannot determine WebP version without pkg-config") + endif () +endif () + +# Find components +if (WebP_INCLUDE_DIR AND WebP_LIBRARY) + set(_WebP_REQUIRED_LIBS_FOUND ON) + set(WebP_LIBS_FOUND "WebP (required): ${WebP_LIBRARY}") +else () + set(_WebP_REQUIRED_LIBS_FOUND OFF) + set(WebP_LIBS_NOT_FOUND "WebP (required)") +endif () + +if ("demux" IN_LIST WebP_FIND_COMPONENTS) + find_library(WebP_DEMUX_LIBRARY + NAMES ${WebP_DEMUX_NAMES} webpdemux libwebpdemux + HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} + ) + + if (WebP_DEMUX_LIBRARY) + if (WebP_FIND_REQUIRED_demux) + list(APPEND WebP_LIBS_FOUND "demux (required): ${WebP_DEMUX_LIBRARY}") + else () + list(APPEND WebP_LIBS_FOUND "demux (optional): ${WebP_DEMUX_LIBRARY}") + endif () + else () + if (WebP_FIND_REQUIRED_demux) + set(_WebP_REQUIRED_LIBS_FOUND OFF) + list(APPEND WebP_LIBS_NOT_FOUND "demux (required)") + else () + list(APPEND WebP_LIBS_NOT_FOUND "demux (optional)") + endif () + endif () +endif () + +if (NOT WebP_FIND_QUIETLY) + if (WebP_LIBS_FOUND) + message(STATUS "Found the following WebP libraries:") + foreach (found ${WebP_LIBS_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () + if (WebP_LIBS_NOT_FOUND) + message(STATUS "The following WebP libraries were not found:") + foreach (found ${WebP_LIBS_NOT_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WebP + FOUND_VAR WebP_FOUND + REQUIRED_VARS WebP_INCLUDE_DIR WebP_LIBRARY _WebP_REQUIRED_LIBS_FOUND + VERSION_VAR WebP_VERSION +) + +if (WebP_LIBRARY AND NOT TARGET WebP::libwebp) + add_library(WebP::libwebp UNKNOWN IMPORTED GLOBAL) + set_target_properties(WebP::libwebp PROPERTIES + IMPORTED_LOCATION "${WebP_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" + ) +endif () + +if (WebP_DEMUX_LIBRARY AND NOT TARGET WebP::demux) + add_library(WebP::demux UNKNOWN IMPORTED GLOBAL) + set_target_properties(WebP::demux PROPERTIES + IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" + ) +endif () + +mark_as_advanced( + WebP_INCLUDE_DIR + WebP_LIBRARY + WebP_DEMUX_LIBRARY +) + +if (WebP_FOUND) + set(WebP_LIBRARIES ${WebP_LIBRARY} ${WebP_DEMUX_LIBRARY}) + set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) +endif () diff --git a/cmake/FindZstd.cmake b/cmake/FindZstd.cmake new file mode 100644 index 0000000000..ce6b774d76 --- /dev/null +++ b/cmake/FindZstd.cmake @@ -0,0 +1,45 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# - Try to find Facebook zstd library +# This will define +# Zstd_FOUND +# Zstd_INCLUDE_DIR +# Zstd_LIBRARY +# + +find_path(Zstd_INCLUDE_DIR NAMES zstd.h) + +find_library(Zstd_LIBRARY_DEBUG NAMES zstdd zstd_staticd) +find_library(Zstd_LIBRARY_RELEASE NAMES zstd zstd_static) + +include(SelectLibraryConfigurations) +SELECT_LIBRARY_CONFIGURATIONS(Zstd) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + Zstd DEFAULT_MSG + Zstd_LIBRARY Zstd_INCLUDE_DIR +) + +mark_as_advanced(Zstd_INCLUDE_DIR Zstd_LIBRARY) + +if(Zstd_FOUND AND NOT (TARGET Zstd::Zstd)) + add_library (Zstd::Zstd UNKNOWN IMPORTED) + set_target_properties(Zstd::Zstd + PROPERTIES + IMPORTED_LOCATION ${Zstd_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${Zstd_INCLUDE_DIR}) +endif() diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index a8d98fdf67..a9f82c361e 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -8,7 +8,10 @@ if (WIN32) # We bundle everything on Windows add_subdirectory(3rdparty/zlib EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/libpng EXCLUDE_FROM_ALL) + add_subdirectory(3rdparty/libwebp EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/xz EXCLUDE_FROM_ALL) + add_subdirectory(3rdparty/zstd EXCLUDE_FROM_ALL) + add_subdirectory(3rdparty/lz4 EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/D3D12MemAlloc EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/winpixeventruntime EXCLUDE_FROM_ALL) set(FFMPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/3rdparty/ffmpeg/include") @@ -47,6 +50,9 @@ else() endif() find_package(ZLIB REQUIRED) + find_package(Zstd REQUIRED) + find_package(LZ4 REQUIRED) + find_package(WebP REQUIRED) ## Use CheckLib package to find module include(CheckLib) @@ -58,15 +64,7 @@ else() if(LINUX) check_lib(AIO aio libaio.h) - # There are two udev pkg config files - udev.pc (wrong), libudev.pc (correct) - # When cross compiling, pkg-config will be skipped so we have to look for - # udev (it'll automatically be prefixed with lib). But when not cross - # compiling, we have to look for libudev.pc. Argh. Hence the silliness below. - if(CMAKE_CROSSCOMPILING) - check_lib(LIBUDEV udev libudev.h) - else() - check_lib(LIBUDEV libudev libudev.h) - endif() + check_lib(LIBUDEV libudev libudev.h) endif() if(X11_API) @@ -117,18 +115,15 @@ add_library(fast_float INTERFACE) target_include_directories(fast_float INTERFACE 3rdparty/rapidyaml/rapidyaml/ext/c4core/src/c4/ext/fast_float/include) add_subdirectory(3rdparty/jpgd EXCLUDE_FROM_ALL) -add_subdirectory(3rdparty/libwebp EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/simpleini EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/imgui EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/cpuinfo EXCLUDE_FROM_ALL) disable_compiler_warnings_for_target(cpuinfo) add_subdirectory(3rdparty/zydis EXCLUDE_FROM_ALL) -add_subdirectory(3rdparty/zstd EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/libzip EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/rcheevos EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/rapidjson EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/discord-rpc EXCLUDE_FROM_ALL) -add_subdirectory(3rdparty/lz4 EXCLUDE_FROM_ALL) if(USE_OPENGL) add_subdirectory(3rdparty/glad EXCLUDE_FROM_ALL)