mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-04-11 19:28:30 +00:00
[cmake] Allow using pre-existing zstd target if it exists (#2390)
adds support for pre-existing `zstd::libzstd` which is useful for projects that bundle their own zstd in a way that doesn't get caught by `CONFIG` Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
@@ -242,27 +242,33 @@ endif()
|
|||||||
# zstd < 1.5.6 does not provide the CMake imported target `zstd::libzstd`.
|
# zstd < 1.5.6 does not provide the CMake imported target `zstd::libzstd`.
|
||||||
# Older versions must be consumed via their pkg-config file.
|
# Older versions must be consumed via their pkg-config file.
|
||||||
if(HTTPLIB_REQUIRE_ZSTD)
|
if(HTTPLIB_REQUIRE_ZSTD)
|
||||||
find_package(zstd 1.5.6 CONFIG)
|
if (NOT TARGET zstd::libzstd)
|
||||||
if(NOT zstd_FOUND)
|
find_package(zstd 1.5.6 CONFIG)
|
||||||
find_package(PkgConfig REQUIRED)
|
if(NOT zstd_FOUND)
|
||||||
pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd)
|
find_package(PkgConfig REQUIRED)
|
||||||
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
|
pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd)
|
||||||
|
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(HTTPLIB_IS_USING_ZSTD TRUE)
|
set(HTTPLIB_IS_USING_ZSTD TRUE)
|
||||||
elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE)
|
elseif(HTTPLIB_USE_ZSTD_IF_AVAILABLE)
|
||||||
find_package(zstd 1.5.6 CONFIG QUIET)
|
if (TARGET zstd::libzstd)
|
||||||
if(NOT zstd_FOUND)
|
set(HTTPLIB_IS_USING_ZSTD TRUE)
|
||||||
find_package(PkgConfig QUIET)
|
else()
|
||||||
if(PKG_CONFIG_FOUND)
|
find_package(zstd 1.5.6 CONFIG QUIET)
|
||||||
pkg_check_modules(zstd QUIET IMPORTED_TARGET libzstd)
|
if(NOT zstd_FOUND)
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(zstd QUIET IMPORTED_TARGET libzstd)
|
||||||
|
|
||||||
if(TARGET PkgConfig::zstd)
|
if(TARGET PkgConfig::zstd)
|
||||||
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
|
add_library(zstd::libzstd ALIAS PkgConfig::zstd)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
# Both find_package and PkgConf set a XXX_FOUND var
|
||||||
|
set(HTTPLIB_IS_USING_ZSTD ${zstd_FOUND})
|
||||||
endif()
|
endif()
|
||||||
# Both find_package and PkgConf set a XXX_FOUND var
|
|
||||||
set(HTTPLIB_IS_USING_ZSTD ${zstd_FOUND})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Used for default, common dirs that the end-user can change (if needed)
|
# Used for default, common dirs that the end-user can change (if needed)
|
||||||
|
|||||||
Reference in New Issue
Block a user