直接集成
此库作者使用cmake构建,因此可以直接集成到xmake项目中:
package("msdf-atlas-gen") add_deps("cmake") set_sourcedir(path.join(os.scriptdir(), "Dionysen/vendor/msdf-atlas-gen")) on_install(function (package) local configs = {} 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")) import("package.tools.cmake").install(package, configs) end) package_end() add_requires("msdf-atlas-gen")
|
❗️但此方法在macOS上链接时找不到符号。
使用xmake重新构建
在msdf-atlas-gen源码目录中新建make.lua
,内容为:
add_requires("freetype", "tinyxml2") target("msdf-atlas-gen") set_kind("static") add_packages("freetype", "tinyxml2") add_includedirs( ".", "msdfgen", "msdf-atlas-gen", "msdfgen/core", "msdfgen/ext", "artery-font-format", {public = true} )
add_files( "msdfgen/*.cpp", "msdfgen/core/*.cpp", "msdfgen/ext/*.cpp", "msdf-atlas-gen/*.cpp" )
set_languages("cxx20")
|
添加的依赖包视情况而定,因为有的包可以系统已经安装,编译时缺什么包添加什么包。