From 5faa0b4adbdc647073bb5d6cf3471b2ca2feb47d Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 20 Feb 2024 00:42:17 +0800 Subject: compile as module --- xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index ee21e88b1..0ae5e78be 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -138,6 +138,12 @@ function _split_gpucodes(flag) return flag:split(",") end +-- is module file? +function _is_modulefile(sourcefile) + local extension = path.extension(sourcefile) + return extension == ".mpp" or extension == ".mxx" or extension == ".cppm" or extension == ".ixx" +end + -- make compiling command function _make_compcmd(compargv, sourcefile, objectfile, vcxprojdir) local argv = {} @@ -1131,6 +1137,11 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc -- for *.c/cpp/cu files else + -- compile as c++ modules + if _is_modulefile(sourcefile) then + vcxprojfile:print("CompileAsCppModule") + end + -- we need to use different object directory and allow parallel building -- -- @see https://github.com/xmake-io/xmake/issues/2016 @@ -1263,6 +1274,11 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour -- for *.c/cpp/cu files else + -- compile as c++ modules + if _is_modulefile(sourcefile) then + vcxprojfile:print("CompileAsCppModule") + end + -- we need to use different object directory and allow parallel building -- -- @see https://github.com/xmake-io/xmake/issues/2016 -- cgit v1.3.1