Page MenuHomePhabricator

[CMAKE] Use CMake built-in to set PIC and PIE

Authored by Fabien on Sep 26 2019, 14:24.



This diff makes proper use of the cmake POSITION_INDEPENDENT_CODE
property to enforce building PIC/PIE.
Because this property does not enforce PIE before version 3.14, the
previous method is kept as a fallback, so the behavior is unchanged.

Test Plan
mkdir buildcmake && cd buildcmake
cmake -GNinja ..
ninja check-security

Check there is no error with both cmake < 3.14 and >= 3.14.

Check it works when cross building for windows (no PIC nor PIE
required), requires D4155 to succeed:

rm -rf *
ninja check-security

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.Sep 26 2019, 14:24
Herald added a reviewer: Restricted Project. · View Herald TranscriptSep 26 2019, 14:24
deadalnix accepted this revision.Sep 27 2019, 12:53
This revision is now accepted and ready to land.Sep 27 2019, 12:53
This revision was automatically updated to reflect the committed changes.