HomePhabricator

[SECP256K1] CMake: allow to select field and scalar implementation

Description

[SECP256K1] CMake: allow to select field and scalar implementation

Summary:
This adds 2 new options, USE_FIELD and USE_SCALAR which can be
32bit or 64bit to force the implementation. If not set (or set to
any other value) the implementation is autodetected.
This is a port of the autotools --with-field and --with-scalar
configure options.

Test Plan:
Run the Travis build (see
https://travis-ci.org/Fabcien/secp256k1/builds/642847130).

cmake -GNinja .. \
  -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux32.cmake \
  -DUSE_FIELD=64bit

Check that cmake outputs an error:

64 finite field requested but the compiler does not support __int128 or
inline assembly
cmake -GNinja .. \
  -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Linux32.cmake \
  -DUSE_SCALAR=64bit

Check that cmake outputs an error:

64 scalar requested but the compiler does not support __int128

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5088

Details