diff --git a/header-unit/Makefile.clang-cl b/header-unit/Makefile.clang-cl new file mode 100644 index 0000000..7c740d1 --- /dev/null +++ b/header-unit/Makefile.clang-cl @@ -0,0 +1,18 @@ +default: hello.exe + +hello.pcm: hello.hpp + clang-cl /std:c++20 /clang:--precompile /clang:-fmodule-header hello.hpp $(CXXFLAGS) + +iostream.pcm: + clang-cl /std:c++20 /clang:--precompile -x c++-system-header iostream $(CXXFLAGS) && \ + echo /clang:-fmodule-file=iostream.pcm > modules.obj || \ + echo "" > modules.obj + +hello.exe: main.cpp hello.pcm iostream.pcm +##### Only -fmodule-file=.pcm works for header units. +##### With the existing implementation -fprebuilt-module-path cannot be used for header units (since they are nominally anonymous). + clang-cl /std:c++20 /clang:-fmodule-file=hello.pcm @modules.obj main.cpp /Fe:hello.exe $(CXXFLAGS) + +clean: + -rm *.pcm *.obj *.exe + -del *.pcm *.obj *.exe diff --git a/module-impl/Makefile.clang-cl b/module-impl/Makefile.clang-cl new file mode 100644 index 0000000..0d1c097 --- /dev/null +++ b/module-impl/Makefile.clang-cl @@ -0,0 +1,18 @@ +default: + clang-cl /std:c++20 /clang:-fmodule-output /clang:-fprebuilt-module-path=. hello.cppm impl.cpp main.cpp /Fe:hello.exe $(CXXFLAGS) + +hello.obj hello.pcm: hello.ixx + clang-cl /std:c++20 /clang:-fmodule-output /c hello.cppm $(CXXFLAGS) + +impl.obj: impl.cpp hello.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c impl.cpp $(CXXFLAGS) + +main.obj: main.cpp hello.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c main.cpp $(CXXFLAGS) + +hello.exe: main.obj hello.obj impl.obj + clang-cl main.obj hello.obj impl.obj /Fe:hello.exe $(CXXFLAGS) + +clean: + -rm *.pcm *.obj *.exe + -del *.pcm *.obj *.exe diff --git a/module-impl/hello.cppm b/module-impl/hello.cppm new file mode 100644 index 0000000..5e7095c --- /dev/null +++ b/module-impl/hello.cppm @@ -0,0 +1 @@ +#include "hello.ixx" \ No newline at end of file diff --git a/module-partition/Makefile.clang-cl b/module-partition/Makefile.clang-cl new file mode 100644 index 0000000..ae1ba38 --- /dev/null +++ b/module-partition/Makefile.clang-cl @@ -0,0 +1,24 @@ +#default: +# The default -fmodule-output of partitions are not same as used by -fprebuilt-module-path. +# clang-cl /std:c++20 /clang:-fmodule-output /clang:-fprebuilt-module-path=. internal.cppm interface.cppm hello.cppm main.cpp /Fe:hello.exe $(CXXFLAGS) + +default: hello.exe + +internal.obj hello-internal.pcm: internal.cppm + clang-cl /std:c++20 /c internal.cppm /clang:-fmodule-output=hello-internal.pcm $(CXXFLAGS) + +interface.obj hello-interface.pcm: interface.cppm hello-internal.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c interface.cppm /clang:-fmodule-output=hello-interface.pcm $(CXXFLAGS) + +hello.obj hello.pcm: hello.ixx hello-interface.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c hello.cppm /clang:-fmodule-output $(CXXFLAGS) + +main.obj: main.cpp hello.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c main.cpp $(CXXFLAGS) + +hello.exe: main.obj hello.obj interface.obj internal.obj + clang-cl main.obj hello.obj interface.obj internal.obj /Fe:hello.exe $(CXXFLAGS) + +clean: + -rm *.pcm *.obj *.exe + -del *.pcm *.obj *.exe diff --git a/module-partition/hello.cppm b/module-partition/hello.cppm new file mode 100644 index 0000000..5e7095c --- /dev/null +++ b/module-partition/hello.cppm @@ -0,0 +1 @@ +#include "hello.ixx" \ No newline at end of file diff --git a/named-module/Makefile.clang-cl b/named-module/Makefile.clang-cl new file mode 100644 index 0000000..e853481 --- /dev/null +++ b/named-module/Makefile.clang-cl @@ -0,0 +1,18 @@ +# https://clang.llvm.org/docs/StandardCPlusPlusModules.html +# BMI: Built Module Interface + +default: + clang-cl /std:c++20 /clang:-fmodule-output /clang:-fprebuilt-module-path=. hello.cppm main.cpp /Fe:hello.exe $(CXXFLAGS) + +hello.obj hello.pcm: hello.cppm + clang-cl /std:c++20 /clang:-fmodule-output /c hello.cppm $(CXXFLAGS) + +main.obj: main.cpp hello.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /c main.cpp $(CXXFLAGS) + +hello.exe: main.obj hello.obj + clang-cl main.obj hello.obj /Fe:hello.exe $(CXXFLAGS) + +clean: + -rm *.pcm *.obj *.exe + -del *.pcm *.obj *.exe diff --git a/shared-lib/Makefile.clang-cl b/shared-lib/Makefile.clang-cl new file mode 100644 index 0000000..a82976e --- /dev/null +++ b/shared-lib/Makefile.clang-cl @@ -0,0 +1,14 @@ +hello.exe: main.cpp hello.lib hello.pcm + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. \ + /Zc:dllexportInlines- \ + main.cpp /Fe:hello.exe hello.lib $(CXXFLAGS) /Zi /link /PDB:hello.exe.pdb /INCREMENTAL:NO + +hello.dll hello.lib hello.pcm: hello.ixx + clang-cl /std:c++20 /clang:-fprebuilt-module-path=. /clang:-fmodule-output /LD \ + /Zc:dllexportInlines- \ + hello.cppm impl.cpp $(CXXFLAGS) /Zi /link /PDB:hello.dll.pdb + +clean: + -rm *.pcm *.obj *.exe *.exp *.lib *.dll *.pdb + -del *.pcm *.obj *.exe *.exp *.lib *.dll *.pdb + diff --git a/shared-lib/hello.cppm b/shared-lib/hello.cppm new file mode 100644 index 0000000..5e7095c --- /dev/null +++ b/shared-lib/hello.cppm @@ -0,0 +1 @@ +#include "hello.ixx" \ No newline at end of file