-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add clang-tidy targets and CI check #1004
base: main
Are you sure you want to change the base?
Conversation
azrogers
commented
Nov 20, 2024
•
edited
Loading
edited
- Added clang-tidy targets to CMake when building for a non-MSVC target. Currently clang-tidy is only set to warn, not raise errors, as there are too many issues to fix for one PR and it's not necessarily worth our time to do them all right now.
- Added the option CESIUM_ENABLE_CLANG_TIDY_ON_BUILD, which will run clang-tidy alongside every build command CMake runs. This slows down the build significantly, so it's disabled by default. However, this allows clang-tidy to be run even with an MSVC target. VSWhere is used on Windows to locate Visual Studio's copy of clang-tidy.
- Addressed part of Fix warnings in public headers #460, allowing warnings to be reported in public headers when cesium-native isn't being included in another CMake project. This has created a lot of errors around our use of int64_t versus size_t in PropertyTable-related classes, which has ended up requiring some pretty thorough changes to resolve.
- Added a CI action to run clang-tidy for each new commit.
After discussion with @kring, we're going to put aside completely resolving #460 for the moment, as adding a ton of casts to PropertyTable headers doesn't seem like it's necessarily the best use of resources right now. This means that CesiumGltf public headers will, for the moment, remain as cesium_target_include_directories(
TARGET
CesiumGltf
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/generated/include
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/generated/src
) With that out of the way, this should be good for review. |
Also, thank you to @lilleyse for the help here, especially with the changes to the code generation which were cherry-picked from his clang-tidy-3 branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I looked through all the non-generated changes, and only had a couple of small comments.
I also tried to build and run clang-tidy locally, though, and ran into some trouble.
First, cesium-native no longer builds on my system with MSVC 14.38:
[build] F:\cesium\cesium-unreal-samples\Plugins\cesium-unreal\extern\cesium-native\CesiumGltfReader\generated\src\GeneratedJsonHandlers.cpp(66,39): error C2220: the following warning is treated as an error [F:\cesium\cesium-unreal-samples\Plugins\cesium-unreal\extern\build\cesium-native\CesiumGltfReader\CesiumGltfReader.vcxproj]
[build] F:\cesium\cesium-unreal-samples\Plugins\cesium-unreal\extern\cesium-native\CesiumGltfReader\generated\src\GeneratedJsonHandlers.cpp(66,39): warning C4455: 'operator ""s': literal suffix identifiers that do not start with an underscore are reserved [F:\cesium\cesium-unreal-samples\Plugins\cesium-unreal\extern\build\cesium-native\CesiumGltfReader\CesiumGltfReader.vcxproj]
This seems like it might be a bug with this older version of the compiler (https://developercommunity.visualstudio.com/t/warning-c4455-issued-when-using-standardized-liter/270349), but sadly Unreal requires us to use this version (or an even older one in some cases, 14.34). It's not obvious to me what changed in this branch to trigger this warning, though. Any ideas?
I also had trouble when compiling Cesium for Unreal's extern
directory against this branch:
[cmake] CMake Error at cesium-native/CMakeLists.txt:110 (cmake_dependent_option):
[cmake] Unknown CMake command "cmake_dependent_option".
I was able to fix this by adding this line to cesium-native's CMakeList.txt, which I think is a reasonable (required?) thing to do
include(CMakeDependentOption)
But I don't know why this only shows up when building cesium-native for Unreal, not when building cesium-native itself. 🤷
Cesium3DTilesContent/test/TestUpgradeBatchTableToExtStructuralMetadata.cpp
Outdated
Show resolved
Hide resolved
I also looked very briefly through the list of new clang-tidy warnings (read: I look at the first couple), and saw this:
Which isn't a good look, because |
Yeah, in this case you would need to include |
The Catch2 GitHub README and tutorial show using |
Looks like this comes down to a change made in the code generator from |
Unless I missed one, I believe I've taken care of all the review comments at the moment, whenever you get a chance to take another look @kring |
The fact that clang-tidy produces a 21k line output for cesium-native is less than ideal. I think it's because each clang-tidy run for each file is independent, so the same headers end up getting checked and producing warnings over and over again. I feel like it would be nice to at least get all this outputted into a log file artifact to download and peruse, rather than almost crashing the browser tab trying to open it on GitHub, but I'm not sure whether that would really be all that useful. |