Page MenuHomePhabricator

[CMAKE] Check for linker flag support
ClosedPublic

Authored by Fabien on Mar 6 2019, 14:18.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABCfe5563885a6e: [CMAKE] Check for linker flag support
Summary

CMake provides no facility to test wheter a linker flag is supported by
the compiler or not. However the CMP0056 policy (Cmake 3.2) enforces
passing the CMAKE_EXE_LINKER_FLAGS to the try_compile() function.
This offers a workaround for testing linker flag validity before adding
them, which is implemented in this diff.

Depends on D2653

Test Plan

In src/CMakeLists.txt replace the line add_linker_flag(-pie) with
add_linker_flag(-pie -foo).
Then:

mkdir buildcmake && cd buildcmake
cmake -GNinja ..
ninja -v

Cmake should output a Performing Test have_linker_foo - Failed line.
Check that the -pie flag is passed on the linker command line but not
the -foo flag.

Diff Detail

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

Event Timeline

Fabien created this revision.Mar 6 2019, 14:18
Herald added a reviewer: Restricted Project. · View Herald TranscriptMar 6 2019, 14:18
Herald added a subscriber: schancel. · View Herald Transcript
Fabien updated this revision to Diff 7652.Mar 8 2019, 12:09

Rebase on top of D2653

Fabien edited the summary of this revision. (Show Details)Mar 8 2019, 12:10
Fabien edited the test plan for this revision. (Show Details)
Fabien updated this revision to Diff 7671.Mar 11 2019, 13:07

Rebase

deadalnix accepted this revision.Mar 12 2019, 20:15
This revision is now accepted and ready to land.Mar 12 2019, 20:15
This revision was automatically updated to reflect the committed changes.