mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[libmagic] Explicitly toggle features. (#37459)
Libmagic supports some compression libraries that by default are enabled unpredictably, if they are found in the system. This PR adds features to the port that enable support for these compression libraries, and makes sure the features are disabled if not specified. Validated by building the port with all features enabled on Windows and Linux, and importing it in a project with static library linkage on Windows.
This commit is contained in:
parent
de7127f52f
commit
109d286a0c
@ -16,7 +16,7 @@ index b05c334..dd4063c 100644
|
||||
dnl Checks for libraries
|
||||
if test "$enable_zlib" != "no"; then
|
||||
- AC_CHECK_LIB(z, gzopen)
|
||||
+ AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib = "yes", have_zlib = "no")
|
||||
+ AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib="yes", have_zlib="no")
|
||||
fi
|
||||
if test "$enable_bzlib" != "no"; then
|
||||
AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
|
||||
|
@ -0,0 +1,27 @@
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 8b54efda..d043fb06 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -191,7 +191,7 @@ if test "$enable_zlib" != "no"; then
|
||||
AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib="yes", have_zlib="no")
|
||||
fi
|
||||
if test "$enable_bzlib" != "no"; then
|
||||
- AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
|
||||
+ AC_SEARCH_LIBS(BZ2_bzCompressInit, [bz2 bz2d], have_bzlib="yes", have_bzlib="no")
|
||||
fi
|
||||
if test "$enable_xzlib" != "no"; then
|
||||
AC_CHECK_LIB(lzma, lzma_stream_decoder)
|
||||
@@ -222,11 +222,11 @@ if test "$ac_cv_header_zlib_h$have_zlib" = "yesyes"; then
|
||||
AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
|
||||
fi
|
||||
if test "$enable_bzlib" = "yes"; then
|
||||
- if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
|
||||
+ if test "$ac_cv_header_bzlib_h$have_bzlib" != "yesyes"; then
|
||||
AC_MSG_ERROR([bzlib support requested but not found])
|
||||
fi
|
||||
fi
|
||||
-if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
|
||||
+if test "$ac_cv_header_bzlib_h$have_bzlib" = "yesyes"; then
|
||||
AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
|
||||
fi
|
||||
if test "$enable_xzlib" = "yes"; then
|
@ -14,6 +14,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
|
||||
"0013-Check-for-backslash-in-argv-0-on-Windows.patch"
|
||||
"0015-MSYS2-Remove-ioctl-call.patch"
|
||||
"0016-Fix-file_famagic-function.patch"
|
||||
"0017-Change-bzlib-name-to-match-CMake-output.patch"
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -31,9 +32,30 @@ if(VCPKG_TARGET_IS_WINDOWS)
|
||||
set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
set(FEATURE_OPTIONS)
|
||||
|
||||
macro(enable_feature feature switch)
|
||||
if("${feature}" IN_LIST FEATURES)
|
||||
list(APPEND FEATURE_OPTIONS "--enable-${switch}")
|
||||
set(has_${feature} 1)
|
||||
else()
|
||||
list(APPEND FEATURE_OPTIONS "--disable-${switch}")
|
||||
set(has_${feature} 0)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
enable_feature("bzip2" "bzlib")
|
||||
enable_feature("zlib" "zlib")
|
||||
enable_feature("lzma" "xzlib")
|
||||
enable_feature("zstd" "zstdlib")
|
||||
|
||||
vcpkg_configure_make(
|
||||
AUTOCONFIG
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
"--disable-lzlib"
|
||||
"--disable-libseccomp"
|
||||
)
|
||||
|
||||
if(VCPKG_CROSSCOMPILING)
|
||||
|
@ -1,8 +1,27 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(unofficial-tre)
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
|
||||
if(WIN32)
|
||||
find_dependency(unofficial-tre)
|
||||
endif()
|
||||
|
||||
if(@has_zlib@)
|
||||
find_dependency(ZLIB)
|
||||
endif()
|
||||
|
||||
if(@has_bzip2@)
|
||||
find_dependency(BZip2)
|
||||
endif()
|
||||
|
||||
if(@has_lzma@)
|
||||
find_dependency(LibLZMA)
|
||||
endif()
|
||||
|
||||
if(@has_zstd@)
|
||||
find_dependency(zstd)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
@ -23,9 +42,14 @@ set_target_properties(unofficial::libmagic::libmagic PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
)
|
||||
|
||||
if(WIN32 AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
|
||||
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
|
||||
set_target_properties(unofficial::libmagic::libmagic PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:unofficial::tre::tre>"
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
"\$<LINK_ONLY:$<$<BOOL:${WIN32}>:unofficial::tre::tre>>"
|
||||
"\$<LINK_ONLY:$<@has_zlib@:ZLIB::ZLIB>>"
|
||||
"\$<LINK_ONLY:$<@has_bzip2@:BZip2::BZip2>>"
|
||||
"\$<LINK_ONLY:$<@has_lzma@:LibLZMA::LibLZMA>>"
|
||||
"\$<LINK_ONLY:$<@has_zstd@:$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>>>"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "libmagic",
|
||||
"version": "5.45",
|
||||
"port-version": 1,
|
||||
"port-version": 2,
|
||||
"description": "This library can be used to classify files according to magic number tests.",
|
||||
"homepage": "https://github.com/file/file",
|
||||
"license": "BSD-2-Clause",
|
||||
@ -22,5 +22,31 @@
|
||||
"name": "tre",
|
||||
"platform": "windows | mingw"
|
||||
}
|
||||
]
|
||||
],
|
||||
"features": {
|
||||
"bzip2": {
|
||||
"description": "Enable bzip2 support",
|
||||
"dependencies": [
|
||||
"bzip2"
|
||||
]
|
||||
},
|
||||
"lzma": {
|
||||
"description": "Enable lzma support",
|
||||
"dependencies": [
|
||||
"liblzma"
|
||||
]
|
||||
},
|
||||
"zlib": {
|
||||
"description": "Enable zlib support",
|
||||
"dependencies": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
"zstd": {
|
||||
"description": "Enable zstd support",
|
||||
"dependencies": [
|
||||
"zstd"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4590,7 +4590,7 @@
|
||||
},
|
||||
"libmagic": {
|
||||
"baseline": "5.45",
|
||||
"port-version": 1
|
||||
"port-version": 2
|
||||
},
|
||||
"libmariadb": {
|
||||
"baseline": "3.3.1",
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "c845ff89796041876594f8b6ef8691e8debb1c82",
|
||||
"version": "5.45",
|
||||
"port-version": 2
|
||||
},
|
||||
{
|
||||
"git-tree": "65715ba20e3afecd46e0fb81326503257174585f",
|
||||
"version": "5.45",
|
||||
|
Loading…
x
Reference in New Issue
Block a user