-
I have a library of cppm files that I want to use in xmake, so I fork the xrepo repository and add an xmake.lua file, but that still doesn't work in xmake. Here's some information: This seems to be similar to example https://github.com/xmake-io/xmake/blob/3a7d68de17f19afadc2f7eec698d54861ecd729d/tests/projects/c++/modules/packages, but I don't understand why this library can't be used normally. @Arthapz |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
ur package is not correct and u missed the configs = { module = true } in ur add_requires here the correct version -- nelib package
package("nelib")
set_kind("library")
set_homepage("https://github.com/hexne/nelib")
set_description("A commonly used tool collection library")
add_urls("https://github.com/hexne/NeLib.git")
add_versions("2024.11.10", "6ec115b4cc87556809567413d1ab94c303179737")
add_configs("modules", {description = "Build with C++20 modules support.", default = false, type = "boolean"})
add_configs("header_only", {description = "Build as a headeronly library.", default = false, type = "boolean"})
set_policy("package.cmake_generator.ninja", true)
add_deps("opencv")
on_load(function (package)
if not package:config("modules") then
package:add("deps", "cmake")
if package:config("header_only") then
package:set("kind", "library", {headeronly = true})
end
end
end)
on_install("linux", function (package)
if not package:config("modules") then
os.cp("*.h", package:installdir("include"))
if not package:config("header_only") then
io.replace("CMakeLists.txt", "NOT GLM_DISABLE_AUTO_DETECTION", "FALSE")
local configs = {"-DGLM_BUILD_TESTS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
import("package.tools.cmake").build(package, configs)
os.cp("**.pcm", package:installdir("include"))
os.cp("**.a", package:installdir("lib"))
end
else
io.writefile("xmake.lua", [[
add_requires("opencv")
target("nelib")
add_packages("opencv")
set_kind("$(kind)")
set_languages("c++20")
add_headerfiles("./**.h", {outputdir = 'nelib'})
add_includedirs(".")
add_files("**.cppm", {public = true})
]])
import("package.tools.xmake").install(package)
end
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
;
}
]]}, {configs = {languages = "c++20", includes = "nelib/tools.h"}}))
end) -- xmake.lua
add_repositories("nelib test-repo")
add_requires("nelib", {configs = {modules = true}})
target("foo")
add_files("src/*.cpp")
add_packages("nelib")
set_policy("build.c++.modules", true) (but your library seems to not build :D)
|
Beta Was this translation helpful? Give feedback.
ur package is not correct and u missed the configs = { module = true } in ur add_requires
here the correct version