Skip to content

Commit 7491a33

Browse files
committed
xmake compilation is supported
1 parent 25ea4e0 commit 7491a33

File tree

8 files changed

+156
-2
lines changed

8 files changed

+156
-2
lines changed

benchmark/xmake.lua

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
add_requires("benchmark 1.9.*", "fmt 11.0.*")
2+
3+
target("benchmark-ipc")
4+
set_kind("binary")
5+
add_deps("imp", "pmr", "ipc")
6+
add_packages("benchmark", "fmt")
7+
if is_os("windows") then
8+
add_ldflags("/subsystem:console")
9+
elseif is_os("linux") then
10+
add_syslinks("rt")
11+
end
12+
on_config(config_target_compilation)
13+
on_config(function (target)
14+
if target:has_tool("cxx", "cl") then
15+
target:add("defines", "_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING")
16+
else
17+
target:add("cxflags", "-Wno-missing-field-initializers"
18+
, "-Wno-unused-variable"
19+
, "-Wno-unused-function"
20+
, "-Wno-unused-result")
21+
end
22+
end)
23+
add_includedirs("$(projectdir)/include"
24+
, "$(projectdir)/src"
25+
, "$(projectdir)/test")
26+
add_files("*.cpp")

include/libimp/log.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ inline auto make_logger(char const * /*ignore*/, char const *name, level level_l
187187
return make_logger(name, make_std_out(), level_limit);
188188
}
189189

190+
#define LIBIMP_LOG_(...) \
191+
auto log \
192+
= [](auto &&...args) noexcept { \
193+
return ::LIBIMP::log::make_logger(__func__, std::forward<decltype(args)>(args)...); \
194+
}(__VA_ARGS__)
195+
190196
} // namespace log
191197
LIBIMP_NAMESPACE_END_
192-
193-
#define LIBIMP_LOG_(...) auto log = ::LIBIMP::log::make_logger(__func__,##__VA_ARGS__)

src/libimp/xmake.lua

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
target("imp")
2+
set_kind("static")
3+
on_config(config_target_compilation)
4+
add_includedirs("$(projectdir)/include", {public = true})
5+
add_includedirs("$(projectdir)/src")
6+
add_files("$(projectdir)/src/libimp/**.cpp")

src/libipc/xmake.lua

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
target("ipc")
2+
if has_config("build_shared_lib") then
3+
set_kind("shared")
4+
add_defines("LIBIMP_LIBRARY_SHARED_BUILDING__")
5+
else
6+
set_kind("static")
7+
end
8+
add_deps("imp", "pmr")
9+
if is_os("linux") then
10+
add_syslinks("pthread", "rt")
11+
elseif is_os("windows") then
12+
add_syslinks("Advapi32")
13+
end
14+
on_config(config_target_compilation)
15+
on_config(function (target)
16+
if (not target:has_tool("cxx", "cl")) and has_config("build_shared_lib") then
17+
target:add("linkgroups", "imp", "pmr", {whole = true})
18+
end
19+
end)
20+
add_includedirs("$(projectdir)/include", {public = true})
21+
add_includedirs("$(projectdir)/src")
22+
add_files("$(projectdir)/src/libipc/**.cpp")

src/libpmr/xmake.lua

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
target("pmr")
2+
set_kind("static")
3+
add_deps("imp")
4+
on_config(config_target_compilation)
5+
add_includedirs("$(projectdir)/include", {public = true})
6+
add_includedirs("$(projectdir)/src")
7+
add_files("$(projectdir)/src/libpmr/**.cpp")

src/xmake.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
includes("libimp", "libpmr", "libipc")

test/xmake.lua

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
add_requires("gtest 1.15.*", {configs = {main = true}})
2+
3+
target("test-ipc")
4+
set_kind("binary")
5+
add_deps("ipc")
6+
add_packages("gtest")
7+
add_links("gtest_main")
8+
if is_os("windows") then
9+
add_ldflags("/subsystem:console")
10+
end
11+
on_config(config_target_compilation)
12+
on_config(function (target)
13+
if target:has_tool("cxx", "cl") then
14+
target:add("cxflags", "/wd4723")
15+
else
16+
target:add("links", "gtest_main")
17+
target:add("cxflags", "-Wno-missing-field-initializers"
18+
, "-Wno-unused-variable"
19+
, "-Wno-unused-function")
20+
end
21+
end)
22+
add_includedirs("$(projectdir)/include"
23+
, "$(projectdir)/src"
24+
, "$(projectdir)/test")
25+
add_files("$(projectdir)/test/**.cpp")

xmake.lua

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
set_project("cpp-ipc")
2+
set_version("2.0.0", {build = "%Y%m%d%H%M"})
3+
4+
-- Build all of libipc's own tests.
5+
option("build_tests") set_default(false)
6+
-- Build all of libipc's own demos.
7+
option("build_demos") set_default(false)
8+
-- Build all of libipc's own benchmark tests.
9+
option("build_benchmarks") set_default(false)
10+
-- Build shared libraries (DLLs).
11+
option("build_shared_lib") set_default(false)
12+
-- Set to ON to build with static CRT on Windows (/MT).
13+
option("use_static_crt") set_default(false)
14+
-- Build with unit test coverage.
15+
option("use_codecov") set_default(false)
16+
option_end()
17+
18+
add_rules("mode.debug", "mode.release")
19+
set_languages("cxx17")
20+
if is_mode("debug") then
21+
if has_config("use_static_crt") then
22+
set_runtimes("MTd")
23+
else
24+
set_runtimes("MDd")
25+
end
26+
else
27+
if has_config("use_static_crt") then
28+
set_runtimes("MT")
29+
else
30+
set_runtimes("MD")
31+
end
32+
end
33+
34+
function config_target_compilation(target)
35+
if target:has_tool("cxx", "cl") then
36+
target:add("defines", "UNICODE", "_UNICODE")
37+
if is_mode("debug") then
38+
target:add("cxflags", "/Zi")
39+
end
40+
else
41+
target:add("cxflags", "-fPIC", "-Wno-attributes")
42+
if has_config("use_codecov") then
43+
target:add("cxflags", "--coverage")
44+
target:add("ldflags", "--coverage")
45+
target:add("syslinks", "gcov")
46+
end
47+
if is_mode("debug") then
48+
target:add("cxflags", "-rdynamic -fsanitize=address")
49+
target:add("ldflags", "-fsanitize=address")
50+
end
51+
end
52+
end
53+
54+
includes("src")
55+
if has_config("build_tests") then
56+
includes("test")
57+
end
58+
if has_config("build_demos") then
59+
includes("demo")
60+
end
61+
if has_config("build_benchmarks") then
62+
includes("benchmark")
63+
end

0 commit comments

Comments
 (0)