use function style target declaration

This commit is contained in:
Arthur LAURENT 2023-10-19 18:57:11 +02:00
parent 9788dee9a2
commit 2040a740a3
No known key found for this signature in database
GPG Key ID: E6701280365D4380

View File

@ -22,8 +22,7 @@ if is_plat("windows") then
add_defines("_CRT_SECURE_NO_WARNINGS") add_defines("_CRT_SECURE_NO_WARNINGS")
end end
target("argparse") target("argparse", function()
do
if get_config("enable_module") then if get_config("enable_module") then
set_languages("c++20") set_languages("c++20")
set_kind("object") set_kind("object")
@ -37,11 +36,10 @@ do
if get_config("enable_module") then if get_config("enable_module") then
add_files("module/argparse.cppm", { install = true }) add_files("module/argparse.cppm", { install = true })
end end
end end)
if get_config("enable_tests") then if get_config("enable_tests") then
target("argparse_tests") target("argparse_tests", function()
do
set_kind("binary") set_kind("binary")
set_languages("c++17") set_languages("c++17")
set_basename("tests") set_basename("tests")
@ -52,11 +50,10 @@ if get_config("enable_tests") then
add_files("test/**.cpp") add_files("test/**.cpp")
add_deps("argparse") add_deps("argparse")
end end)
if get_config("enable_module") then if get_config("enable_module") then
target("argparse_module_tests") target("argparse_module_tests", function()
do
set_kind("binary") set_kind("binary")
set_languages("c++20") set_languages("c++20")
set_basename("module_tests") set_basename("module_tests")
@ -70,14 +67,13 @@ if get_config("enable_tests") then
add_files("test/argparse_details.cppm") add_files("test/argparse_details.cppm")
add_deps("argparse") add_deps("argparse")
end end)
end end
end end
if get_config("enable_samples") then if get_config("enable_samples") then
for _, sample_file in ipairs(os.files("samples/*.cpp")) do for _, sample_file in ipairs(os.files("samples/*.cpp")) do
target(path.basename(sample_file)) target(path.basename(sample_file), function()
do
set_kind("binary") set_kind("binary")
set_languages("c++17") set_languages("c++17")
@ -86,6 +82,6 @@ if get_config("enable_samples") then
set_policy("build.c++.modules", false) set_policy("build.c++.modules", false)
add_deps("argparse") add_deps("argparse")
end end)
end end
end end