Page MenuHomePhabricator

[SECP256K1] CMake: Fix in-tree build
ClosedPublic

Authored by Fabien on Jan 29 2020, 07:48.

Details

Summary

The in-tree build is broken when building with CMake.
This is because the "standard" CMake call pattern has a dual meaning
depending on the context: the path argument is eigher the source root
(which is what we want) OR the build root if a build already exists
in this path.
This second case occurs when building in-tree as the source root is also
the build root; as a consequence when configuring the native executables
to generate the build tree to the native directory, the root build
files are updated instead.

Macro notabug:

This diff fixes the issue by specifiying both the source root and build
root when calling CMake to configure the native executables. The build
directory is created by CMake if needed, so the initial mkdir becomes
useless and is removed.

Test Plan

Build the secp256k1 project both in-tree and out-of-tree.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
secp256k1_fix_in_tree_build
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9185
Build 16320: Default Diff Build & Tests
Build 16319: arc lint + arc unit

Event Timeline

deadalnix requested changes to this revision.Jan 29 2020, 14:03
deadalnix added a subscriber: deadalnix.

This disallow deleting the native folder and have it be rebuilt.

This revision now requires changes to proceed.Jan 29 2020, 14:03
Fabien requested review of this revision.Jan 29 2020, 14:20

Did you run it and failed to rebuild ? Because it's working for me.

If you're worried about the mkdir removal, the directory is created by CMake if it doesn't exist thanks to the -B option.

This revision is now accepted and ready to land.Jan 29 2020, 15:39
This revision was automatically updated to reflect the committed changes.