SKIP_LINTING.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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, as well as compiling header files as part of
  9. :prop_tgt:`VERIFY_INTERFACE_HEADER_SETS`. By setting ``SKIP_LINTING`` on a
  10. source file, the mentioned linting tools will not be executed for that
  11. 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`, or :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`
  29. are executed, they will skip analyzing the ``generatedBindings.cpp`` file.
  30. By using the ``SKIP_LINTING`` property, you can selectively exclude specific
  31. source files from the linting process. This allows you to focus the
  32. linting tools on the relevant parts of your project, enhancing the efficiency
  33. and effectiveness of the linting workflow.