Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C++20 module #165

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Next Next commit
add xmake build system
Arthapz committed Oct 27, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 42357745f7a73ebff735fea9df7e5ba071c2821d
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/
.xmake
tests/test_main
tests/*.o
*.*~
1 change: 1 addition & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
indent_type = "Spaces"
104 changes: 104 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
set_xmakever("2.8.2")
set_project("frozen")

set_version("1.1.0", { build = "%Y%m%d%H%M" })

option("enable_module")
option("enable_tests")
option("enable_benchmark")

target("frozen")
do
set_languages("c++latest")
if get_config("enable_module") then
set_kind("object")
else
set_kind("headeronly")
end

add_includedirs("include", { public = true })
add_headerfiles("include/frozen/**.hpp")
if get_config("enable_module") then
add_files("module/frozen.cppm", { install = true })
end
end
target_end()

if get_config("enable_benchmark") then
add_requires("benchmark")
target("frozen.benchmark")
do
set_kind("binary")
set_languages("c++17")

add_files("benchmarks/**.cpp")

if not get_config("enable_benchmark_str_search") then
remove_files("benchmarks/bench_str_search.cpp")
end

add_packages("benchmark")

add_deps("frozen")
end
end

if get_config("enable_tests") then
target("frozen.tests")
do
set_kind("binary")
set_languages("c++latest")
add_rules("mode.coverage")
add_files("tests/**.cpp")
remove_files("tests/no_exceptions.cpp")

add_cxxflags("/W3", "/WX", { tools = { "cl", "clang_cl" } })
add_cxxflags("-Wall", "-Wextra", "-Wpedantic", "-Werror", "-Wshadow", { tools = { "cl", "clang_cl" } })

if is_plat("windows") then
add_cxxflags("/W3", "/WX", { tools = "icc" })
else
add_cxxflags("-Wall", "-Werror", { tools = "icc" })
end

add_deps("frozen")
end

target("frozen.tests.noexcept")
do
set_kind("binary")
set_languages("c++latest")
add_rules("mode.coverage")
set_basename("test_no_exceptions")

add_files("tests/no_exceptions.cpp")

add_cxxflags("/W3", "/WX", { tools = { "cl", "clang_cl" } })
add_cxxflags("-Wall", "-Wextra", "-Wpedantic", "-Werror", "-Wshadow", { tools = { "cl", "clang_cl" } })

if is_plat("windows") then
add_cxxflags("/W3", "/WX", { tools = { "icc" } })
else
add_cxxflags("-Wall", "-Werror", { tools = { "icc" } })
end

add_deps("frozen")
end

for _, example in ipairs(os.files("examples/*.cpp")) do
target("frozen.example." .. path.basename(example))
do
set_kind("binary")
set_languages("c++latest")

add_files(example)

add_deps("frozen")

if path.basename(example) == "html_entities_map" then
add_cxxflags("-fconstexpr-steps=123456789", { tools = "clang" })
add_cxxflags("-fconstexpr-ops-limit=12345678910", { tools = "gcc" })
end
end
end
end