Add static analyser support (#41)
* add static analyzers * use 'ON/OFF' for Ccache settings
This commit is contained in:
parent
ecc71786e5
commit
9ede321e5d
2 changed files with 33 additions and 6 deletions
|
@ -83,11 +83,12 @@ See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options
|
||||||
|
|
||||||
### Additional tools
|
### Additional tools
|
||||||
|
|
||||||
The project includes an [tools.cmake](cmake/tools.cmake) file that can be used to import additional tools on-demand through CMake configuration arguments.
|
The test and standalone subprojects include the [tools.cmake](cmake/tools.cmake) file which is used to import additional tools on-demand through CMake configuration arguments.
|
||||||
The following are currently supported.
|
The following are currently supported.
|
||||||
|
|
||||||
- `-DUSE_SANITIZER=<Address | Memory | MemoryWithOrigins | Undefined | Thread | Leak | 'Address;Undefined'>`
|
- **Sanitizers**, by setting `-DUSE_SANITIZER=<Address | Memory | MemoryWithOrigins | Undefined | Thread | Leak | 'Address;Undefined'>`.
|
||||||
- `-DUSE_CCACHE=<YES | NO>`
|
- **Static Analyzers**, by setting `-DUSE_STATIC_ANALYZER=<clang-tidy | iwyu | cppcheck>`, or a combination of those in quotation marks, separated by semicolons. Arguments can be passed to the analyzers by setting the `CLANG_TIDY_ARGS`, `IWYU_ARGS` or `CPPCHECK_ARGS` variables.
|
||||||
|
- **Ccache**, by setting `-DUSE_CCACHE=<ON | OFF>`.
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,40 @@ include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
||||||
|
|
||||||
# enables sanitizers support using the the `USE_SANITIZER` flag
|
# enables sanitizers support using the the `USE_SANITIZER` flag
|
||||||
# available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
# available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
||||||
if (USE_SANITIZER)
|
if (USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME StableCoder-cmake-scripts
|
NAME StableCoder-cmake-scripts
|
||||||
GITHUB_REPOSITORY StableCoder/cmake-scripts
|
GITHUB_REPOSITORY StableCoder/cmake-scripts
|
||||||
GIT_TAG 3a469d8251660a97dbf9e0afff0a242965d40277
|
GIT_TAG 3d2d5a9fb26f0ce24e3e4eaeeff686ec2ecfb3fb
|
||||||
)
|
)
|
||||||
|
|
||||||
include(${StableCoder-cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
if (USE_SANITIZER)
|
||||||
|
include(${StableCoder-cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (USE_STATIC_ANALYZER)
|
||||||
|
if ("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
||||||
|
SET(CLANG_TIDY ON CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
SET(CLANG_TIDY OFF CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
if ("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
||||||
|
SET(IWYU ON CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
SET(IWYU OFF CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
if ("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
||||||
|
SET(CPPCHECK ON CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
SET(CPPCHECK OFF CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(${StableCoder-cmake-scripts_SOURCE_DIR}/tools.cmake)
|
||||||
|
|
||||||
|
clang_tidy(${CLANG_TIDY_ARGS})
|
||||||
|
include_what_you_use(${IWYU_ARGS})
|
||||||
|
cppcheck(${CPPCHECK_ARGS})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# enables CCACHE support through the USE_CCACHE flag
|
# enables CCACHE support through the USE_CCACHE flag
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue