tools/cmake: fix compilation with host libzstd-dev

cmake's find_package looks at host paths first for some reason. Switch
to using pkgconfig for the search, matching other modules.

Fixes: 3848cf458e ("tools/cmake: Build without some included libs")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2022-09-30 01:42:51 -07:00
parent 3b23227d43
commit 0e3d51ccae
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -630,8 +630,13 @@ IF(ENABLE_ZSTD)
SET(ZSTD_FIND_QUIETLY TRUE)
ENDIF (ZSTD_INCLUDE_DIR)
- FIND_PATH(ZSTD_INCLUDE_DIR zstd.h)
- FIND_LIBRARY(ZSTD_LIBRARY NAMES zstd libzstd)
+ IF(UNIX)
+ FIND_PACKAGE(PkgConfig QUIET)
+ PKG_SEARCH_MODULE(PC_ZSTD libzstd)
+ ENDIF()
+
+ FIND_PATH(ZSTD_INCLUDE_DIR zstd.h HINTS ${PC_ZSTD_INCLUDEDIR} ${PC_ZSTD_INCLUDE_DIRS})
+ FIND_LIBRARY(ZSTD_LIBRARY NAMES zstd HINTS ${PC_ZSTD_LIBDIR} ${PC_ZSTD_LIBRARY_DIRS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD DEFAULT_MSG ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
ELSE(ENABLE_ZSTD)