summaryrefslogtreecommitdiff
path: root/build2/cxx-modules/modtest/buildfile
blob: 4aa779b4aea3cf201de6198661ba1bf263236cb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# file      : buildfile
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

./: exe{driver}

lib{bar}: {hxx cxx}{bar}

# The order of prerequisites is important. When compile with VC using modules
# the module interface file (foo.ifc) should be produced before module consumer
# (driver.cxx) is compiled. The same reasoning is applied for bar.ifc.
#
if ($cxx.id == "msvc")
  exe{driver}: lib{bar} {hxx cxx}{foo} cxx{driver}
else
  exe{driver}: {hxx cxx}{foo} cxx{driver} lib{bar}

cxx.poptions =+ -I$src_root

if ($use_modules == true)
{
  cxx.poptions += -DMODTEST_USE_MODULES

  if ($cxx.id == "clang")
  {
    # -Wno-ambiguous-macro - required to suppress "ambiguous expansion of macro
    #                        MODTEST_MACRO" warning (do not mix up with macro
    #                        redefinition warning). The warning seems to follow
    #                        from a module macro leakage effect.
    #
    cxx.coptions += -fmodules -Wno-ambiguous-macro \
      -fmodules-cache-path=$out_root/modcache

    # Frankly not 100% sure this is required.
    #
    obj{foo}: cxx.coptions += -fmodule-name=foo
    obj{bar}: cxx.coptions += -fmodule-name=bar
  }
  if ($cxx.id == "clang-apple")
  {
    # While compiler (8.0.0) recognizes -fmodules* options they just get
    # ignored as no import module semantics is assigned to #include directive.
    #
    # @@ Can there be something wrong with module.modulemap file?
    #
    cxx.coptions += -fmodules -fmodules-cache-path=$out_root/modcache

    obj{foo}: cxx.coptions += -fmodule-name=foo
    obj{bar}: cxx.coptions += -fmodule-name=bar
  }
  elif ($cxx.id == "msvc")
  {
    # /module:interface - produce ifc-file if there is interface definition
    #                     in a file.
    # /module:search    - directory to search for ifc-files. In its absense
    #                     need to use /module:reference <ifc-file> option when
    #                     compile consumer of the module represented with the
    #                     corresponding ifc-file.
    #
    cxx.coptions += /experimental:module /module:interface \
                    /module:search $out_base
  }
}