I am trying to set up llvm-mca to work with CMake. The official documentation gives simple commands to output the info such as.
$ clang foo.c -O2 -target x86_64-unknown-unknown -S -o - | llvm-mca -mcpu=btver2
This works great for simple files. However I am unsure how to expand on this and implement it for a practical project using CMake.
Posting my answer for anyone else who comes across this problem.
Probably worth mentioning that I am by no means an expert, however LLVM MCA seems to be used for analysing a single file at a time. This means that a simple command (such as I pasted above when asking the question) is realistically sufficient.
Also an error 'error: no assembly instructions found'. Means optimizations probably removed all code between the START and END macros (happened to me when I made a simple program for testing).