Page MenuHomePhabricator

[CMAKE] Avoid warning when checking flags
ClosedPublic

Authored by Fabien on Aug 5 2019, 11:13.

Details

Summary

When the CHECK_<C|CXX>_COMPILER_FLAG() is called, it uses the output
variable name to write a #define <output variable> statement to some
temporary source file that will get build to check whether the target
flag is supported.

The issue is that CMake variables character set is wider than C or C++
preprocessor #define directive. This causes the compiler to issue a
warning, which is not user facing but logged to the CMake files.

The variables used with these functions then require more sanitizing to
prevent this warning to occur. If CMake changes its behavior and starts
failing the check when a warning is detected that will cause our build
to fail. At the moment, there is no behavior change introduced by this
diff.

Test Plan
cmake -GNinja ..
cat CMakeFiles/CMakeOutput.log | grep "whitespace after the macro name"

Should return nothing.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cmake_sanitize_for_define
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 7044
Build 12135: Bitcoin ABC Buildbot (legacy)
Build 12134: arc lint + arc unit

Event Timeline

There is a risk of collision doing it this way. Adding the hex code of the invalid character or something would be preferable. But this isn't meant to be used billions of time, so it can do for now.

This revision is now accepted and ready to land.Aug 6 2019, 05:54
This revision was automatically updated to reflect the committed changes.