Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

develroot / xmake.lua

3.3 KiB · Raw · Log

-- Copyright (c) 2026 Progmasoft.
-- SPDX-License-Identifier: LGPL-3.0-or-later

set_project("Catch3")
set_version("0.4.0")
set_languages("cxx17")
set_warnings("all")

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

-- yyjson and pugixml, compiled into the library.
includes("third_party/yyjson", "third_party/pugixml")

-- The Catch2-compatible engine, the Catch3 runner, which replaced Catch2's
-- session, command line and reporters, property testing and snapshots. The
-- library and the code that includes it need C++17.
target("catch3")
    set_kind("static")
    -- The files are Catch3 and Catch3Main, as in CMake and Meson, so that an
    -- installed Catch3 links with -lCatch3 and -lCatch3Main.
    set_basename("Catch3")
    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_catch3 = import("catch3_config")
        configure_catch3.main(generated_include, repository_root)
        target:add("includedirs", generated_include, {public = true})
    end)
    add_files("src/Progmasoft/Catch3/**.cpp")
    remove_files("src/Progmasoft/Catch3/Internal/Main.cpp")
    add_files(
        "src/Progmasoft/Runner/*.cpp",
        "src/Progmasoft/Results.cpp",
        "src/Progmasoft/XmlWriter.cpp",
        "src/Progmasoft/ChoiceShrinker.cpp",
        "src/Progmasoft/Mock.cpp",
        "src/Progmasoft/StrategyContext.cpp",
        "src/Progmasoft/PropertyEngine.cpp",
        "src/Progmasoft/Snapshot.cpp"
    )
    add_includedirs("src", {public = true})
    add_headerfiles("src/(Progmasoft/**.hpp)")
    -- The JSON and XML libraries of the runner are compiled into its own
    -- translation units.
    add_deps("catch3_yyjson", "catch3_pugixml")

target("catch3_main")
    set_kind("static")
    set_basename("Catch3Main")
    add_files("src/Progmasoft/Catch3/Internal/Main.cpp")
    add_deps("catch3")
    add_includedirs("src", generated_include, {public = true})

target("ProgmasoftPropertyTests")
    set_kind("binary")
    add_files(
        "tests/Progmasoft/Generators.tests.cpp",
        "tests/Progmasoft/Property.tests.cpp",
        "tests/Progmasoft/ForAll.tests.cpp",
        "tests/Progmasoft/Results.tests.cpp",
        "tests/Progmasoft/Runner.tests.cpp",
        "tests/Progmasoft/RunnerUnits.tests.cpp",
        "tests/Progmasoft/RunnerPlanner.tests.cpp",
        "tests/Progmasoft/RunnerOptions.tests.cpp",
        "tests/Progmasoft/RunnerConfig.tests.cpp",
        "tests/Progmasoft/RunnerAnalysis.tests.cpp",
        "tests/Progmasoft/RunnerImport.tests.cpp",
        "tests/Progmasoft/RunnerCoverage.tests.cpp",
        "tests/Progmasoft/RunnerOutput.tests.cpp",
        "tests/Progmasoft/Snapshot.tests.cpp",
        "tests/Progmasoft/Stateful.tests.cpp",
        "tests/Progmasoft/Strategy.tests.cpp",
        "src/Progmasoft/Catch3/Internal/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 catch3_main for downstream consumers.
    add_deps("catch3")