mimalloc provides CMake targets:

  find_package(mimalloc CONFIG REQUIRED)
  target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:mimalloc-static>,mimalloc-static,mimalloc>)

And use mimalloc in your sources as:

  #include <mimalloc.h>
  #include <stdio.h>
  int main(int argc, char** argv) {
    int* p = mi_malloc_tp(int);
    *p = mi_version();
    printf("mimalloc version: %d\n", *p);
    mi_free(p);
    return 0;
  }

With the `cxx` feature the static library is compiled as C++, so enable C++
in your project when linking statically (e.g. `project(main C CXX)`).

On Windows with dynamic linkage, call a mimalloc API function (e.g.
`mi_version()`) to ensure the allocator DLL (`mimalloc.dll`, or
`mimalloc-secure.dll` with the secure feature; `-debug` variants in Debug)
is loaded. Keep the matching `mimalloc-redirect*.dll` alongside it.
See https://github.com/microsoft/mimalloc/blob/dev3/bin/readme.md
