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 #290

Merged
merged 10 commits into from
Oct 20, 2023
Prev Previous commit
fix module compilation with clang on windows when std module is disabled
Arthapz committed Oct 20, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 24569f69e8ac1e2ebf8df685c8fa12da8b4135b9
9 changes: 8 additions & 1 deletion module/argparse.cppm
Original file line number Diff line number Diff line change
@@ -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 <argparse/argparse.hpp>
#endif

export module argparse;

#ifdef ARGPARSE_MODULE_USE_STD_MODULE
import std;
#endif

extern "C++" {
#include <argparse/argparse.hpp>
}
#endif


export namespace argparse {
using argparse::nargs_pattern;
5 changes: 4 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -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")