SKIP_LINTING.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. SKIP_LINTING
  2. ------------
  3. .. versionadded:: 3.27
  4. This property allows you to exclude a specific source file
  5. from the linting process. The linting process involves running
  6. tools such as :prop_tgt:`<LANG>_CPPLINT`, :prop_tgt:`<LANG>_CLANG_TIDY`,
  7. :prop_tgt:`<LANG>_CPPCHECK`, and :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
  8. on the source files. By setting ``SKIP_LINTING`` on a source file,
  9. the mentioned linting tools will not be executed for that
  10. particular file.
  11. Example
  12. ^^^^^^^
  13. Consider a C++ project that includes multiple source files,
  14. such as ``main.cpp``, ``things.cpp``, and ``generatedBindings.cpp``.
  15. In this example, you want to exclude the ``generatedBindings.cpp``
  16. file from the linting process. To achieve this, you can utilize
  17. the ``SKIP_LINTING`` property with the :command:`set_source_files_properties`
  18. command as shown below:
  19. .. code-block:: cmake
  20. add_executable(MyApp main.cpp things.cpp generatedBindings.cpp)
  21. set_source_files_properties(generatedBindings.cpp PROPERTIES
  22. SKIP_LINTING ON
  23. )
  24. In the provided code snippet, the ``SKIP_LINTING`` property is set to true
  25. for the ``generatedBindings.cpp`` source file. As a result, when the linting
  26. tools specified by :prop_tgt:`<LANG>_CPPLINT`, :prop_tgt:`<LANG>_CLANG_TIDY`,
  27. :prop_tgt:`<LANG>_CPPCHECK`, or :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
  28. are executed, they will skip analyzing the ``generatedBindings.cpp`` file.
  29. By using the ``SKIP_LINTING`` property, you can selectively exclude specific
  30. source files from the linting process. This allows you to focus the
  31. linting tools on the relevant parts of your project, enhancing the efficiency
  32. and effectiveness of the linting workflow.