Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/xmake.lua
blob: a865f98d1760b007dac38d1af64603d8c9902852 (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
-- Copyright (c) 2026 Progmasoft.
-- SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1

set_project("Catch3")
set_version("3.16.0")
set_languages("cxx14")
set_warnings("all")

local repository_root = os.projectdir()
local generated_include = path.join(repository_root, ".xmake", "generated")
add_moduledirs(path.join(repository_root, "buildsupport"))

-- Keep upstream Catch2's compilation baseline and project identity intact.
target("catch2")
    set_kind("static")
    set_languages("cxx14")
    on_load(function(target)
        -- File I/O is restricted to Xmake's script domain, so generate here
        -- rather than while the declarative project file is being evaluated.
        local configure_catch2 = import("catch2_config")
        configure_catch2.main(generated_include, repository_root)
        target:add("includedirs", generated_include, {public = true})
    end)
    add_files("src/catch2/**.cpp")
    remove_files("src/catch2/internal/catch_main.cpp")
    add_includedirs("src", {public = true})
    add_headerfiles("src/catch2/**.hpp", {prefixdir = ""})

target("catch2_main")
    set_kind("static")
    set_languages("cxx14")
    add_files("src/catch2/internal/catch_main.cpp")
    add_deps("catch2")
    add_includedirs("src", generated_include, {public = true})

-- Compile Progmasoft's implementation separately from the compatibility engine.
target("ProgmasoftCatch3")
    set_kind("static")
    set_languages("cxx20")
    add_headerfiles("src/Progmasoft/**.hpp", {prefixdir = ""})
    add_files(
        "src/Progmasoft/Results.cpp",
        "src/Progmasoft/Snapshot.cpp",
        "src/Progmasoft/XmlWriter.cpp"
    )
    add_includedirs("src", {public = true})
    add_deps("catch2", {public = true})

target("ProgmasoftPropertyTests")
    set_kind("binary")
    set_languages("cxx20")
    add_files(
        "tests/Progmasoft/Generators.tests.cpp",
        "tests/Progmasoft/Property.tests.cpp",
        "tests/Progmasoft/Results.tests.cpp",
        "tests/Progmasoft/Snapshot.tests.cpp",
        "src/catch2/internal/catch_main.cpp"
    )
    add_includedirs("src", generated_include)
    -- MSVC's linker does not discover an otherwise unreferenced main() in a
    -- static archive. Compile the compatibility entry point into this test
    -- executable while retaining catch2_main for downstream consumers.
    add_deps("ProgmasoftCatch3")