SKIP_LINTING.rst 1.8 KB

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