add_library(common STATIC
    bspinfo.cc
    bspfile.cc
    bspfile_generic.cc
    bspfile_q1.cc
    bspfile_q2.cc
    bsputils.cc
    bspxfile.cc
    cmdlib.cc
    decompile.cc
    entdata.cc
    log.cc
    mathlib.cc
    parser.cc
    qvec.cc
    threads.cc
    fs.cc
    imglib.cc
    settings.cc
    prtfile.cc
    debugger.natvis
    ../include/common/aabb.hh
    ../include/common/aligned_allocator.hh
    ../include/common/bitflags.hh
    ../include/common/bspinfo.hh
    ../include/common/bspfile.hh
    ../include/common/bspfile_generic.hh
    ../include/common/bspfile_q1.hh
    ../include/common/bspfile_q2.hh
    ../include/common/bsputils.hh
    ../include/common/bspxfile.hh
    ../include/common/cmdlib.hh
    ../include/common/decompile.hh
    ../include/common/entdata.h
    ../include/common/iterators.hh
    ../include/common/log.hh
    ../include/common/mathlib.hh
    ../include/common/numeric_cast.hh
    ../include/common/parser.hh
    ../include/common/polylib.hh
    ../include/common/qvec.hh
    ../include/common/json.hh
    ../include/common/parallel.hh
    ../include/common/threads.hh
    ../include/common/fs.hh
    ../include/common/imglib.hh
    ../include/common/settings.hh
    ../include/common/prtfile.hh
    ../include/common/vectorutils.hh
)

target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb TBB::tbbmalloc fmt::fmt nlohmann_json::nlohmann_json)

target_precompile_headers(common INTERFACE
        <filesystem>
        <functional>
        <array>
        <any>
        <bitset>
        <cassert>
        <cinttypes>
        <cstdarg>
        <iostream>
        <fstream>
        <list>
        <mutex>
        <vector>
        <set>
        <unordered_set>
        <map>
        <unordered_map>
        <memory>
        <optional>
        <sstream>
        <string>
        <shared_mutex>
        <type_traits>
        <variant>
        <fmt/core.h>
        <tbb/scalable_allocator.h>
        <tbb/task_group.h>
        <tbb/task_group.h>
        <tbb/parallel_for.h>
        <tbb/parallel_for_each.h>
)
