Checks to see if a compiler flag is valid, and if so, adds it to CFLAGS for the current profile.
check_compile_flag '-Wmissing-prototypes';
check_compile_flag '-Wno-missing-prototypes' { negate; }
Because gcc will not create a warning or error when a compiler flag is prefixed with '-Wno-', it is necessary to check the compiler flag without the '-Wno-' prefix. To do this, append a statement block to the check, and add the negate attribute.
But be aware that some warning flags such as '-Wno-poison-system-directories' for MacOS/clang do not have an opposite and cannot be tested with the negate attribute.
Generated Name: Prefix: cf_
The leading '-' or '-W' is removed from the name.
Example: cf_missing_prototypes
add-compile-flag '-DNO_DEPRECATED';
Adds a compiler flag without any validation.
check_compile_flag '-Wall';
check_compile_flag '-Wformat';
Wiki: Home
Wiki: Syntax
Wiki: SyntaxAttrCompileFlag
Wiki: SyntaxAttrHeader
Wiki: SyntaxAttrName
Wiki: SyntaxCheck