friendlyanon / cmake-init

The missing CMake project initializer
GNU General Public License v3.0
2.03k stars 76 forks source link

clang-tidy preset should enforce CMAKE_CXX_COMPILER=clang++ #122

Closed htfy96 closed 4 hours ago

htfy96 commented 4 hours ago

When CMAKE_CXX_CLANG_TIDY is set, cmake passes all configured compilation flags to clang-tidy. However, if the project is configured with CMAKE_CXX_COMPILER=gcc, the compilation flags might not work for clang-tidy, leading to weird clang-tidy error.

It would be best if ci.yml could installl clang and set CMAKE_CXX_COMPILER=clang++ when running ci preset. A module that prints out a warning message when CMAKE_CXX_CLANG_TIDY is set but compiler is not clang(++) will also be helpful

friendlyanon commented 4 hours ago

GHA already provides Clang on the Ubuntu image: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md

I'm not sure what I need to change here. You have to know your tools at the end of the day and I believe the common usecase is already satisfied by the generated projects. If you have needs beyond what is provided, you only have to understand the corresponding tools without cmake-init getting in your way, as that is one of my goals with this project generator, after which you can adjust things accordingly.

Writing any kind of module for this would also be pointless. You should strive to write LESS code when it comes to CMake, especially when such a requirement can be trivially satisfied in a static environment such as CI. You just parameterize the build in CI to meet your requirements.