File: Findzstd.cmake

package info (click to toggle)
zarchive 0.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: cpp: 1,010; ansic: 517; makefile: 8; sh: 4
file content (31 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# SPDX-FileCopyrightText: 2022 Andrea Pappacoda <andrea@pappacoda.it>
# SPDX-License-Identifier: ISC

include(FindPackageHandleStandardArgs)

find_package(zstd CONFIG QUIET)
if (zstd_FOUND)
	# Use upstream zstdConfig.cmake if possible
	if (NOT TARGET zstd::zstd)
		if (TARGET zstd::libzstd_shared)
			add_library(zstd::zstd ALIAS zstd::libzstd_shared)
		endif()
	endif()
	find_package_handle_standard_args(zstd CONFIG_MODE)
else()
	# Fallback to pkg-config otherwise
	find_package(PkgConfig)
	if (PKG_CONFIG_FOUND)
		pkg_search_module(libzstd IMPORTED_TARGET GLOBAL libzstd)
		if (libzstd_FOUND)
			add_library(zstd::zstd ALIAS PkgConfig::libzstd)
		endif()
	endif()

	find_package_handle_standard_args(zstd
		REQUIRED_VARS
			libzstd_LINK_LIBRARIES
			libzstd_FOUND
		VERSION_VAR libzstd_VERSION
	)
endif()