Customizing C‐STAT rulesets - iarsystems/cmake-tutorial GitHub Wiki
When using the native IAR C-STAT integration in CMake, the standard checks are selected by default. There are situations in which a specific set of rules needs to be selected in order to comply with project requirements. In this article, it is assumed that such a project lives within a version-controlled environment.
For using a customized selection of rules you can follow these simple steps:
- Use the IAR C-STAT Manifest File Handler (
ichecks
) to create the manifest file. - Comment out any undesired rule.
- Set the
CMAKE_<lang>_ICSTAT
variable with an additional parameter to point to your customized ruleset manifest file. - Check-in the customized manifest file in the project's version control system.
For this example we will use all the rules from the CERT C ruleset and save it as "my-cert.rules" in the same location in which the project's top-level CMakeLists.txt
is located:
/path/to/ichecks --package cert --output /path/to/project/my-cert.rules
Now to get to the subset of relevant rules for our project, edit "my-cert.rules" and comment out the undesired ones using #
. For example:
...
CERT-DCL40-C
CERT-DCL41-C
#CERT-ENV30-C
#CERT-ENV31-C
CERT-ENV32-C
#CERT-ENV33-C
#CERT-ENV34-C
CERT-ERR30-C_a
CERT-ERR30-C_b
...
Then, in the CMakeLists.txt
project, we can refer to that location using ${CMAKE_SOURCE_DIR}
when enabling C-STAT for the project:
set(CMAKE_C_ICSTAT "${CMAKE_IAR_CSTAT}" --checks ${CMAKE_SOURCE_DIR}/my-cert.rules)
Test your changes in your project and, once you are satisfied with the results, commit "my-cert.rules" to the project's version control.