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.
 
 
 

60 lines
2.5 KiB

package("glfw")
set_homepage("https://www.glfw.org/")
set_description("GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development.")
add_urls("https://github.com/glfw/glfw/archive/$(version).tar.gz",
"https://github.com/glfw/glfw.git")
add_versions("3.3.2", "98768e12e615fbe9f3386f5bbfeb91b5a3b45a8c4c77159cef06b1f6ff749537")
add_versions("3.3.4", "cc8ac1d024a0de5fd6f68c4133af77e1918261396319c24fd697775a6bc93b63")
add_configs("glfw_include", {description = "Choose submodules enabled in glfw", default = "none", type = "string", values = {"none", "vulkan", "glu", "glext", "es2", "es3"}})
on_fetch(function (package, opt)
if opt.system and package.find_package then
if package:is_plat("linux") then
return package:find_package("apt::libglfw3-dev", opt)
end
end
end)
add_deps("cmake")
if is_plat("macosx") then
add_frameworks("Cocoa", "IOKit")
elseif is_plat("windows") then
add_syslinks("user32", "shell32", "gdi32")
elseif is_plat("mingw") then
add_syslinks("gdi32")
elseif is_plat("linux") then
-- TODO: add wayland support
add_deps("libx11", "libxrandr", "libxrender", "libxinerama", "libxfixes", "libxcursor", "libxi", "libxext")
add_syslinks("dl", "pthread")
add_defines("_GLFW_X11")
end
on_load(function (package)
package:add("defines", "GLFW_INCLUDE_" .. package:config("glfw_include"):upper())
end)
on_install("macosx", "windows", "linux", "mingw", function (package)
local configs = {"-DGLFW_BUILD_DOCS=OFF", "-DGLFW_BUILD_TESTS=OFF", "-DGLFW_BUILD_EXAMPLES=OFF"}
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:is_plat("windows") then
table.insert(configs, "-DUSE_MSVC_RUNTIME_LIBRARY_DLL=" .. (package:config("vs_runtime"):startswith("MT") and "OFF" or "ON"))
end
if package:is_plat("linux") then
import("package.tools.cmake").install(package, configs, {packagedeps = {"libxrender", "libxfixes", "libxext", "libx11"}})
else
import("package.tools.cmake").install(package, configs)
end
end)
on_test(function (package)
assert(package:check_csnippets({test = [[
void test() {
glfwInit();
glfwTerminate();
}
]]}, {configs = {languages = "c11"}, includes = "GLFW/glfw3.h"}))
end)