-1

I am a newbie in CMake.

In my previous complie tools waf. it provide me a cpplint.py script that can check cpp source file's format, and make complie failed if the format is not good.

but i want to switch to Cmake. I googled this, but seems still cant make it work.

Can anyone tell me how to run cpplint.py when i make by cmake?

it will be of great help for me if you can list an example.

Thanks a lot

xyhuang
  • 414
  • 3
  • 11
  • 1
    The first output of googling for "cmake cpplint" gives [that question](https://stackoverflow.com/questions/51582604/how-to-use-cpplint-code-style-checking-with-cmake). Have you checked it? – Tsyvarev Feb 07 '21 at 15:53
  • @Tsyvarev thanks for attention, i read that answer, but still not work for me. i do as the first two answers, but cpplint doesnt work – xyhuang Feb 08 '21 at 00:18
  • Please, edit the question post and describe **what** exactly **have you tried**: the code and the behavior which contradicts to your expectations. Also, specify which CMake version do you use: e.g. variable [CMAKE_CXX_CPPLINT](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CPPLINT.html) appears only in CMake 3.8. – Tsyvarev Feb 08 '21 at 07:05

1 Answers1

0

I recommend to not try to run the linter through cmake and to instead keep cmake purely for building. You could for example use a shell script to run both linter and build in one command:

#!/bin/sh

set -e   # makes script fail if any subprocess fails

python cpplint.py OPTIONS
cmake OPTIONS
cmake --build OPTIONS
eerorika
  • 232,697
  • 12
  • 197
  • 326