xmake compilation is supported

This commit is contained in:
mutouyun 2024-09-28 20:43:05 +08:00
parent 25ea4e016c
commit 7491a33d85
8 changed files with 156 additions and 2 deletions

26
benchmark/xmake.lua Normal file
View File

@ -0,0 +1,26 @@
add_requires("benchmark 1.9.*", "fmt 11.0.*")
target("benchmark-ipc")
set_kind("binary")
add_deps("imp", "pmr", "ipc")
add_packages("benchmark", "fmt")
if is_os("windows") then
add_ldflags("/subsystem:console")
elseif is_os("linux") then
add_syslinks("rt")
end
on_config(config_target_compilation)
on_config(function (target)
if target:has_tool("cxx", "cl") then
target:add("defines", "_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING")
else
target:add("cxflags", "-Wno-missing-field-initializers"
, "-Wno-unused-variable"
, "-Wno-unused-function"
, "-Wno-unused-result")
end
end)
add_includedirs("$(projectdir)/include"
, "$(projectdir)/src"
, "$(projectdir)/test")
add_files("*.cpp")

View File

@ -187,7 +187,11 @@ inline auto make_logger(char const * /*ignore*/, char const *name, level level_l
return make_logger(name, make_std_out(), level_limit);
}
#define LIBIMP_LOG_(...) \
auto log \
= [](auto &&...args) noexcept { \
return ::LIBIMP::log::make_logger(__func__, std::forward<decltype(args)>(args)...); \
}(__VA_ARGS__)
} // namespace log
LIBIMP_NAMESPACE_END_
#define LIBIMP_LOG_(...) auto log = ::LIBIMP::log::make_logger(__func__,##__VA_ARGS__)

6
src/libimp/xmake.lua Normal file
View File

@ -0,0 +1,6 @@
target("imp")
set_kind("static")
on_config(config_target_compilation)
add_includedirs("$(projectdir)/include", {public = true})
add_includedirs("$(projectdir)/src")
add_files("$(projectdir)/src/libimp/**.cpp")

22
src/libipc/xmake.lua Normal file
View File

@ -0,0 +1,22 @@
target("ipc")
if has_config("build_shared_lib") then
set_kind("shared")
add_defines("LIBIMP_LIBRARY_SHARED_BUILDING__")
else
set_kind("static")
end
add_deps("imp", "pmr")
if is_os("linux") then
add_syslinks("pthread", "rt")
elseif is_os("windows") then
add_syslinks("Advapi32")
end
on_config(config_target_compilation)
on_config(function (target)
if (not target:has_tool("cxx", "cl")) and has_config("build_shared_lib") then
target:add("linkgroups", "imp", "pmr", {whole = true})
end
end)
add_includedirs("$(projectdir)/include", {public = true})
add_includedirs("$(projectdir)/src")
add_files("$(projectdir)/src/libipc/**.cpp")

7
src/libpmr/xmake.lua Normal file
View File

@ -0,0 +1,7 @@
target("pmr")
set_kind("static")
add_deps("imp")
on_config(config_target_compilation)
add_includedirs("$(projectdir)/include", {public = true})
add_includedirs("$(projectdir)/src")
add_files("$(projectdir)/src/libpmr/**.cpp")

1
src/xmake.lua Normal file
View File

@ -0,0 +1 @@
includes("libimp", "libpmr", "libipc")

25
test/xmake.lua Normal file
View File

@ -0,0 +1,25 @@
add_requires("gtest 1.15.*", {configs = {main = true}})
target("test-ipc")
set_kind("binary")
add_deps("ipc")
add_packages("gtest")
add_links("gtest_main")
if is_os("windows") then
add_ldflags("/subsystem:console")
end
on_config(config_target_compilation)
on_config(function (target)
if target:has_tool("cxx", "cl") then
target:add("cxflags", "/wd4723")
else
target:add("links", "gtest_main")
target:add("cxflags", "-Wno-missing-field-initializers"
, "-Wno-unused-variable"
, "-Wno-unused-function")
end
end)
add_includedirs("$(projectdir)/include"
, "$(projectdir)/src"
, "$(projectdir)/test")
add_files("$(projectdir)/test/**.cpp")

63
xmake.lua Normal file
View File

@ -0,0 +1,63 @@
set_project("cpp-ipc")
set_version("2.0.0", {build = "%Y%m%d%H%M"})
-- Build all of libipc's own tests.
option("build_tests") set_default(false)
-- Build all of libipc's own demos.
option("build_demos") set_default(false)
-- Build all of libipc's own benchmark tests.
option("build_benchmarks") set_default(false)
-- Build shared libraries (DLLs).
option("build_shared_lib") set_default(false)
-- Set to ON to build with static CRT on Windows (/MT).
option("use_static_crt") set_default(false)
-- Build with unit test coverage.
option("use_codecov") set_default(false)
option_end()
add_rules("mode.debug", "mode.release")
set_languages("cxx17")
if is_mode("debug") then
if has_config("use_static_crt") then
set_runtimes("MTd")
else
set_runtimes("MDd")
end
else
if has_config("use_static_crt") then
set_runtimes("MT")
else
set_runtimes("MD")
end
end
function config_target_compilation(target)
if target:has_tool("cxx", "cl") then
target:add("defines", "UNICODE", "_UNICODE")
if is_mode("debug") then
target:add("cxflags", "/Zi")
end
else
target:add("cxflags", "-fPIC", "-Wno-attributes")
if has_config("use_codecov") then
target:add("cxflags", "--coverage")
target:add("ldflags", "--coverage")
target:add("syslinks", "gcov")
end
if is_mode("debug") then
target:add("cxflags", "-rdynamic -fsanitize=address")
target:add("ldflags", "-fsanitize=address")
end
end
end
includes("src")
if has_config("build_tests") then
includes("test")
end
if has_config("build_demos") then
includes("demo")
end
if has_config("build_benchmarks") then
includes("benchmark")
end