Format.cmake
Format.cmake copied to clipboard
CI failing with `cmake --build build --target check-format`, complains about CPM.cmake even though it is excluded
This doesn't fail when running it locally, only on CI.
Local run:
[TerraGen]$ cmake --build build --target check-format
[0/2] Re-checking globbed directories...
[2/2] cd /home/kyle/Documents/TerraGen && /usr/bin/python3.9 /home/kyle/Documents/TerraGen/build/_deps/...ke-src/git-clang-format.py --binary=/usr/bin/clang-format --ci 4b825dc642cb6eb9a060e54bf8d69288fbee4904
clang-format did not modify any files
CI run:
cmake --build /home/runner/work/TerraGen/TerraGen/build --target check-format --config Debug
shell: /usr/bin/bash -e {0}
env:
BUILD_TYPE: Debug
CMake Error at build/_deps/format.cmake-src/cmake-format.cmake:53 (message):
cmake/CPM.cmake needs to be reformatted
Any idea what I'm doing wrong here?
I'm getting a similar error when using ModernCppStarter. This is my log:
Run cmake --build build --target check-format
clang-format did not modify any files
Built target check-clang-format
CMake Error at /Users/runner/work/MyProject/MyProject/cpm_modules/format.cmake/e25a26778e5810b3fa49523bf8cadf5f71bacc26/cmake-format.cmake:53 (message):
../CMakeLists.txt needs to be reformatted
make[3]: *** [_deps/format.cmake-build/CMakeFiles/check-cmake-format] Error 1
make[2]: *** [_deps/format.cmake-build/CMakeFiles/check-cmake-format.dir/all] Error 2
make[1]: *** [_deps/format.cmake-build/CMakeFiles/check-format.dir/rule] Error 2
make: *** [check-format] Error 2
Error: Process completed with exit code 2.
The only difference w.r.t. the original repo is the project name (MyProject instead of Greeter).
Hm, one way this can happen is when different versions of formatters are installed on CI and local systems. Can you check that cmake-format --version returns the same value on both systems?
Since then I have completely reinstalled a few utilities (including clang-format) and now everything works as expected. At this point I am not sure what the problem was exactly, but I would suggest trying to reinstall/update the tools involved.