package An official xmake package repository
https://xrepo.xmake.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.9 KiB
68 lines
2.9 KiB
package("libflac") |
|
|
|
set_homepage("https://xiph.org/flac") |
|
set_description("Free Lossless Audio Codec") |
|
set_license("BSD") |
|
|
|
set_urls("https://github.com/xiph/flac/archive/$(version).tar.gz", |
|
"https://github.com/xiph/flac.git") |
|
|
|
add_versions("1.3.3", "668cdeab898a7dd43cf84739f7e1f3ed6b35ece2ef9968a5c7079fe9adfe1689") |
|
add_patches("1.3.3", path.join(os.scriptdir(), "patches", "1.3.3", "cmake.patch"), "49baa40ab70d63e74cfc3f0cc2f13824545a618ceaeffdd51d3333d90b37fd32") |
|
|
|
if is_plat("mingw") and is_subhost("msys") then |
|
add_extsources("pacman::flac") |
|
elseif is_plat("linux") then |
|
add_extsources("pacman::flac", "apt::libflac++-dev", "apt::libflac-dev") |
|
elseif is_plat("macosx") then |
|
add_extsources("brew::flac") |
|
end |
|
|
|
add_deps("cmake", "libogg") |
|
|
|
if is_plat("linux") then |
|
add_syslinks("m") |
|
end |
|
|
|
on_load("windows", "mingw", function (package) |
|
if not package:config("shared") then |
|
package:add("defines", "FLAC__NO_DLL") |
|
end |
|
end) |
|
|
|
on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package) |
|
|
|
local configs = {} |
|
table.insert(configs, "-DBUILD_CXXLIBS=OFF") |
|
table.insert(configs, "-DBUILD_DOCS=OFF") |
|
table.insert(configs, "-DBUILD_PROGRAMS=OFF") |
|
table.insert(configs, "-DBUILD_EXAMPLES=OFF") |
|
table.insert(configs, "-DBUILD_TESTING=OFF") |
|
table.insert(configs, "-DBUILD_UTILS=OFF") |
|
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) |
|
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
|
table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") |
|
|
|
-- fix, undefined reference to `__memset_chk' |
|
-- @see https://github.com/msys2/MINGW-packages/issues/5803 |
|
if package:config("shared") and package:is_plat("mingw") then |
|
io.replace("CMakeLists.txt", "add_definitions(-DHAVE_CONFIG_H)", "add_definitions(-DHAVE_CONFIG_H -D_FORTIFY_SOURCE=0)", {plain = true}) |
|
end |
|
|
|
-- we pass libogg as packagedeps instead of findOgg.cmake (it does not work) |
|
local libogg = package:dep("libogg"):fetch() |
|
if libogg then |
|
local links = table.concat(table.wrap(libogg.links), " ") |
|
io.replace("CMakeLists.txt", "find_package(OGG REQUIRED)", "", {plain = true}) |
|
io.replace("src/libFLAC/CMakeLists.txt", |
|
[[ |
|
if(TARGET Ogg::ogg) |
|
target_link_libraries(FLAC PUBLIC Ogg::ogg) |
|
endif()]], "target_link_libraries(FLAC PUBLIC " .. links .. ")", {plain = true}) |
|
end |
|
import("package.tools.cmake").install(package, configs, {packagedeps = "libogg"}) |
|
end) |
|
|
|
on_test(function (package) |
|
assert(package:has_cfuncs("FLAC__format_sample_rate_is_valid", {includes = "FLAC/format.h"})) |
|
end)
|
|
|