add_library(musl STATIC
    src/complex/__cexp.c
    src/complex/carg.c
    src/complex/cargf.c
    src/complex/cexp.c
    src/math/__cos.c
    src/math/__cosdf.c
    src/math/__expo2.c
    src/math/__expo2f.c
    src/math/__fpclassify.c
    src/math/__fpclassifyf.c
    src/math/__math_divzero.c
    src/math/__math_divzerof.c
    src/math/__math_invalid.c
    src/math/__math_invalidf.c
    src/math/__rem_pio2.c
    src/math/__rem_pio2_large.c
    src/math/__rem_pio2f.c
    src/math/__sin.c
    src/math/__sindf.c
    src/math/__tan.c
    src/math/__tandf.c
    src/math/acos.c
    src/math/acosf.c
    src/math/acosh.c
    src/math/acoshf.c
    src/math/asin.c
    src/math/asinf.c
    src/math/asinh.c
    src/math/asinhf.c
    src/math/atan.c
    src/math/atan2.c
    src/math/atan2f.c
    src/math/atanf.c
    src/math/atanh.c
    src/math/atanhf.c
    src/math/cbrt.c
    src/math/cbrtf.c
    src/math/ceil.c
    src/math/ceilf.c
    src/math/copysign.c
    src/math/copysignf.c
    src/math/cos.c
    src/math/cosf.c
    src/math/cosh.c
    src/math/coshf.c
    src/math/erf.c
    src/math/erff.c
    src/math/exp.c
    src/math/exp2.c
    src/math/exp2f.c
    src/math/exp2f_data.c
    src/math/exp_data.c
    src/math/expf.c
    src/math/expm1.c
    src/math/expm1f.c
    src/math/fabs.c
    src/math/fabsf.c
    src/math/fdim.c
    src/math/fdimf.c
    src/math/floor.c
    src/math/floorf.c
    src/math/fma.c
    src/math/fmaf.c
    src/math/fmax.c
    src/math/fmaxf.c
    src/math/fmin.c
    src/math/fminf.c
    src/math/fmod.c
    src/math/fmodf.c
    src/math/frexp.c
    src/math/frexpf.c
    src/math/hypot.c
    src/math/hypotf.c
    src/math/ilogb.c
    src/math/ilogbf.c
    src/math/j0.c
    src/math/j1.c
    src/math/jn.c
    src/math/ldexp.c
    src/math/lgamma.c
    src/math/lgamma_r.c
    src/math/lgammaf.c
    src/math/lgammaf_r.c
    src/math/log.c
    src/math/log10.c
    src/math/log10f.c
    src/math/log1p.c
    src/math/log1pf.c
    src/math/log2.c
    src/math/log2_data.c
    src/math/log2f.c
    src/math/log2f_data.c
    src/math/log_data.c
    src/math/logb.c
    src/math/logbf.c
    src/math/logf.c
    src/math/logf_data.c
    src/math/modf.c
    src/math/modff.c
    src/math/nan.c
    src/math/nanf.c
    src/math/nextafter.c
    src/math/nextafterf.c
    src/math/nexttoward.c
    src/math/nexttowardf.c
    src/math/pow.c
    src/math/pow_data.c
    src/math/powf.c
    src/math/powf_data.c
    src/math/remainder.c
    src/math/remainderf.c
    src/math/remquo.c
    src/math/remquof.c
    src/math/rint.c
    src/math/rintf.c
    src/math/round.c
    src/math/roundf.c
    src/math/scalbn.c
    src/math/scalbnf.c
    src/math/signgam.c
    src/math/sin.c
    src/math/sincos.c
    src/math/sincosf.c
    src/math/sinf.c
    src/math/sinh.c
    src/math/sinhf.c
    src/math/sqrt.c
    src/math/sqrt_data.c
    src/math/sqrtf.c
    src/math/tan.c
    src/math/tanf.c
    src/math/tanh.c
    src/math/tanhf.c
    src/math/tgamma.c
    src/math/tgammaf.c
    src/math/trunc.c
    src/math/truncf.c
)

target_include_directories(musl
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/src
        ${CMAKE_CURRENT_SOURCE_DIR}/src/internal
        ${PROJECT_SOURCE_DIR}/include
        ${PROJECT_SOURCE_DIR}/include/msvcrt
)

target_compile_definitions(musl
    PRIVATE
        _ACRTIMP=
        _NO_CRT_MATH_INLINE
)

target_compile_options(musl
    PRIVATE
        -fno-builtin
        -fno-strict-aliasing
        -fno-omit-frame-pointer
        -Wno-misleading-indentation
        -ffunction-sections
)
