summaryrefslogtreecommitdiffstats
path: root/externals/find-modules/Findzstd.cmake
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2022-08-21 19:42:42 +0200
committerGitHub <noreply@github.com>2022-08-21 19:42:42 +0200
commitb99596e3120bdf4eb9ab8c3e868a0fff55cd79d0 (patch)
tree3a6440d9e59c8dea7f71cfd87f17cf1d7d93c23a /externals/find-modules/Findzstd.cmake
parentMerge pull request #8676 from abouvier/no-check-sub (diff)
parentbuild(externals): rename Findopus to FindOpus (diff)
downloadyuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar.gz
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar.bz2
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar.lz
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar.xz
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.tar.zst
yuzu-b99596e3120bdf4eb9ab8c3e868a0fff55cd79d0.zip
Diffstat (limited to 'externals/find-modules/Findzstd.cmake')
-rw-r--r--externals/find-modules/Findzstd.cmake60
1 files changed, 11 insertions, 49 deletions
diff --git a/externals/find-modules/Findzstd.cmake b/externals/find-modules/Findzstd.cmake
index f0c56f499..f4031eb70 100644
--- a/externals/find-modules/Findzstd.cmake
+++ b/externals/find-modules/Findzstd.cmake
@@ -1,57 +1,19 @@
-# SPDX-FileCopyrightText: 2020 yuzu Emulator Project
+# SPDX-FileCopyrightText: 2022 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
-find_package(PkgConfig QUIET)
-pkg_check_modules(PC_zstd QUIET libzstd)
+find_package(PkgConfig)
-find_path(zstd_INCLUDE_DIR
- NAMES zstd.h
- PATHS ${PC_zstd_INCLUDE_DIRS}
-)
-find_library(zstd_LIBRARY
- NAMES zstd
- PATHS ${PC_zstd_LIBRARY_DIRS}
-)
-
-if(zstd_INCLUDE_DIR)
- file(STRINGS "${zstd_INCLUDE_DIR}/zstd.h" _zstd_version_lines
- REGEX "#define[ \t]+ZSTD_VERSION_(MAJOR|MINOR|RELEASE)")
- string(REGEX REPLACE ".*ZSTD_VERSION_MAJOR *\([0-9]*\).*" "\\1" _zstd_version_major "${_zstd_version_lines}")
- string(REGEX REPLACE ".*ZSTD_VERSION_MINOR *\([0-9]*\).*" "\\1" _zstd_version_minor "${_zstd_version_lines}")
- string(REGEX REPLACE ".*ZSTD_VERSION_RELEASE *\([0-9]*\).*" "\\1" _zstd_version_release "${_zstd_version_lines}")
- set(zstd_VERSION "${_zstd_version_major}.${_zstd_version_minor}.${_zstd_version_release}")
- unset(_zstd_version_major)
- unset(_zstd_version_minor)
- unset(_zstd_version_release)
- unset(_zstd_version_lines)
+if (PKG_CONFIG_FOUND)
+ pkg_search_module(libzstd IMPORTED_TARGET GLOBAL libzstd)
+ if (libzstd_FOUND)
+ add_library(zstd::zstd ALIAS PkgConfig::libzstd)
+ endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zstd
- FOUND_VAR zstd_FOUND
- REQUIRED_VARS
- zstd_LIBRARY
- zstd_INCLUDE_DIR
- zstd_VERSION
- VERSION_VAR zstd_VERSION
-)
-
-if(zstd_FOUND)
- set(zstd_LIBRARIES ${zstd_LIBRARY})
- set(zstd_INCLUDE_DIRS ${zstd_INCLUDE_DIR})
- set(zstd_DEFINITIONS ${PC_zstd_CFLAGS_OTHER})
-endif()
-
-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_COMPILE_OPTIONS "${PC_zstd_CFLAGS_OTHER}"
- INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
- )
-endif()
-
-mark_as_advanced(
- zstd_INCLUDE_DIR
- zstd_LIBRARY
+ REQUIRED_VARS
+ libzstd_LINK_LIBRARIES
+ libzstd_FOUND
+ VERSION_VAR libzstd_VERSION
)