Page MenuHomePhabricator

[CMAKE] Avoid warning when checking flags

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



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

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

Should return nothing.

Diff Detail

rABC Bitcoin ABC
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien created this revision.Aug 5 2019, 11:13
Herald added a reviewer: Restricted Project. · View Herald TranscriptAug 5 2019, 11:13
Fabien updated this revision to Diff 10610.Aug 5 2019, 15:13

Add missing newline.

deadalnix accepted this revision.Aug 6 2019, 05:54

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.