cmake checker是一个搜索违反“现代”cmake规则的行为的工具。
cmake-checker的Python项目详细描述
cmake检查器
cmake checker是一个搜索违反“现代”cmake规则的行为的工具。
使用量
usage: __main__.py [-h] [--warn-only] [--reporter {console,junit}]
[-o OUTPUT_FILE] [--whitelist WHITELIST]
PATH [PATH ...]
positional arguments:
PATH Path to the file or directory where the checks should
be done
optional arguments:
-h, --help show this help message and exit
--warn-only Program will return 0 even if violations are found
--reporter {console,junit}
Specify type of reporter to output
-o OUTPUT_FILE, --output-file OUTPUT_FILE
Output results to file with given name
--whitelist WHITELIST
Whitelist file with rules to ignore certain files or
dirs (.gitignore style)
工具警告
的原因file(GLOB ...)
- cmake将无法正确跟踪磁盘上新文件的依赖项。如果没有cmakelists.txt文件在源 添加或删除,则生成的生成系统无法知道何时要求cmake重新生成。
- 无法确保仅添加所需的文件。globbing可能会收集您不需要的零散文件。
功能
add_compile_options
add_compile_definitions
link_libraries
add_definitions
include_directories
函数在目录作用域而不是目标作用域上工作。列出的每个函数都有 应使用的目标作用域的等效项。
属性
COMPILE_<LANG>_FLAGS
应该为目标设置这些属性-不能全局修改
带子句的关闭命令
endif
endfunction
endmacro
endforeach
示例:
macro(foo ...) ... endmacro(foo)
设置/取消设置包括
ENV
CACHE
../..
在target_sources
函数中在函数声明之外设置/取消设置
PARENT_SCOPE
禁用检查的可能性
如果由于任何特定原因需要禁用检查,可以使用:
# cmake-check disable
...
# cmake-check enable