Skip to content

Instantly share code, notes, and snippets.

@Necklaces
Forked from vladiant/Makefile
Created July 18, 2022 10:34
Show Gist options
  • Select an option

  • Save Necklaces/7077a3ef6490960768c67d6b5437efa0 to your computer and use it in GitHub Desktop.

Select an option

Save Necklaces/7077a3ef6490960768c67d6b5437efa0 to your computer and use it in GitHub Desktop.

Revisions

  1. @vladiant vladiant created this gist Jul 10, 2021.
    23 changes: 23 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    main : main.o hello.o
    g++-11 -o main main.o hello.o

    main.o : main.cpp gcm.cache/smd.hello.gcm
    g++-11 -fPIC -fmodules-ts -std=c++20 -o main.o -c main.cpp

    hello.o: hello.cpp
    g++-11 -fPIC -fmodules-ts -std=c++20 -o hello.o -c hello.cpp

    gcm.cache/smd.hello.gcm: hello.o
    @test -f $@ || rm -f $<
    @test -f $@ || $(MAKE) $<

    clean:
    rm hello.o main.o gcm.cache/smd.hello.gcm

    clean-gcm:
    rm gcm.cache/smd.hello.gcm

    test:
    ./main

    all: main
    13 changes: 13 additions & 0 deletions hello.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // hello.cpp
    module;
    #include <iostream>
    #include <string_view>

    export module smd.hello;

    export namespace hello {
    void hello(std::string_view name)
    {
    std::cout << "Hello, " << name << "! \n";
    }
    } // namespace hello
    8 changes: 8 additions & 0 deletions main.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    // main.cxx

    import smd.hello;

    int main()
    {
    hello::hello("Steve");
    }
    1 change: 1 addition & 0 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    https://github.com/steve-downey/module-hw/blob/master/main.cpp