Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions packages/g/glslang-nihui/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package("glslang-nihui")
set_homepage("https://github.com/nihui/glslang/")
set_description("nihui's fork of KhronosGroup/glslang for C++14 compatibility. This package is designed for Tencent/ncnn.")
set_license("Apache-2.0")

add_urls("https://github.com/nihui/glslang.git")

add_versions("20250916", "cpp14-2") -- 8cd77a808d0bffa442ae9462d5e3a8141892ba5a
add_versions("20250503", "a9ac7d5f307e5db5b8c4fbf904bdba8fca6283bc")

if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end

add_deps("cmake")
if is_plat("linux", "bsd") then
add_syslinks("pthread")
end

on_load(function (package)
package:add("links", "glslang", "glslang-default-resource-limits")
end)

on_install(function (package)
-- glslang will add a debug lib postfix for win32 platform, disable this to fix compilation issues under windows
io.replace("CMakeLists.txt", 'set(CMAKE_DEBUG_POSTFIX "d")', [[
message(WARNING "Disabled CMake Debug Postfix for xmake package generation")
]], {plain = true})

if package:is_plat("wasm") then
-- wasm-ld doesn't support --no-undefined
io.replace("CMakeLists.txt", [[add_link_options("-Wl,--no-undefined")]], "", {plain = true})
end

local configs = {
"-DGLSLANG_TESTS=OFF",
"-DBUILD_EXTERNAL=OFF",
"-DENABLE_PCH=OFF",
"-DENABLE_GLSLANG_BINARIES=OFF",
"-DENABLE_SPVREMAPPER=OFF",
"-DENABLE_OPT=OFF",
"-DENABLE_HLSL=OFF",
"-DENABLE_EXCEPTIONS=OFF",
"-DENABLE_RTTI=OFF"
}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))

import("package.tools.cmake").install(package, configs)

os.cp("glslang/MachineIndependent/**.h", package:installdir("include", "glslang", "MachineIndependent"))
os.cp("glslang/Include/**.h", package:installdir("include", "glslang", "Include"))
end)

on_test(function (package)
assert(package:has_cxxfuncs("ShInitialize", {configs = {languages = "c++11"}, includes = "glslang/Public/ShaderLang.h"}))
end)
Loading