banach-space / clang-tutor

A collection of out-of-tree Clang plugins for teaching and learning
The Unlicense
659 stars 62 forks source link

added a cmake presets #28

Open phreed opened 11 months ago

phreed commented 11 months ago

Newer versions of cmake support CMakePresets.json which provide a convenient way of specifying platform and toolchain settings. This PR provides is a simple example which works with Ubuntu 20.04

I think it would be useful to update the documentation to indicate that llvm v16 is required and which packages are needed.

https://apt.llvm.org/

Here is the /etc/apt/sources.list.d/llvm.list

deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main
deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main

And, here the signatures.

sudo wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc

Here are the packages I installed to get this to work.

sudo wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo apt-get install clang-16 lldb-16 lld-16
sudo apt-get install libllvm-16-ocaml-dev libllvm16 llvm-16 llvm-16-dev llvm-16-doc llvm-16-examples llvm-16-runtime
sudo apt-get install clang-16 clang-tools-16 clang-16-doc libclang-common-16-dev libclang-16-dev libclang1-16 clang-format-16 python3-clang-16 clangd-16 clang-tidy-16

Then to configure and build.

cmake --preset hello
cmake --build --preset hello

I have not added a test to run the generated executable.

banach-space commented 11 months ago

Thanks for working on this!

I think it would be useful to update the documentation to indicate that llvm v16 is required and which packages are needed.

I don't follow - that's already documented: https://github.com/banach-space/clang-tutor#platform-support-and-requirements. What am I missing?

I have not added a test to run the generated executable.

Please add a test. You could update https://github.com/banach-space/clang-tutor/blob/main/.github/workflows/x86-ubuntu.yml to build HelloWorld with and without CMake presets.

phreed commented 11 months ago

You are right the Ubuntu documentation is correct. I do not know what I was thinking.

I will add the ctest.