From 24569f69e8ac1e2ebf8df685c8fa12da8b4135b9 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Fri, 20 Oct 2023 10:50:58 +0200 Subject: [PATCH] fix module compilation with clang on windows when std module is disabled --- module/argparse.cppm | 9 ++++++++- xmake.lua | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/module/argparse.cppm b/module/argparse.cppm index fdf2ff41..625283e1 100644 --- a/module/argparse.cppm +++ b/module/argparse.cppm @@ -29,15 +29,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +module; + +#ifndef ARGPARSE_MODULE_USE_STD_MODULE +#include +#endif + export module argparse; #ifdef ARGPARSE_MODULE_USE_STD_MODULE import std; -#endif extern "C++" { #include } +#endif + export namespace argparse { using argparse::nargs_pattern; diff --git a/xmake.lua b/xmake.lua index b5fd5b4f..cc33c03a 100644 --- a/xmake.lua +++ b/xmake.lua @@ -4,6 +4,7 @@ set_project("argparse") set_version("2.9.0", { build = "%Y%m%d%H%M" }) option("enable_module") +option("enable_std_import", { defines = "ARGPARSE_MODULE_USE_STD_MODULE" }) option("enable_tests") option("enable_samples") @@ -28,7 +29,9 @@ target("argparse", function() if get_config("enable_module") then set_languages("c++20") set_kind("static") -- static atm because of a XMake bug, headeronly doesn't generate package module metadata - else + end + + add_options("enable_std_import") add_includedirs("include", { public = true }) add_headerfiles("include/argparse/argparse.hpp")