11 Commits

Author SHA1 Message Date
Tim Ruffing
e4af41c61b
Merge bitcoin-core/secp256k1#1249: cmake: Add SECP256K1_LATE_CFLAGS configure option
42f8c5140227dbdd8ae7eaaecd914e705e1b12d0 cmake: Add `SECP256K1_LATE_CFLAGS` configure option (Hennadii Stepanov)

Pull request description:

  This PR enables users to override compiler flags that have been set by the CMake-based build system, such as warning flags.

  The Autotools-based build system has the same feature out-of-the-box.

  See more details [here](https://github.com/bitcoin-core/secp256k1/issues/1235#issuecomment-1465330925).

  Here are some examples of the new option usage:
  ```
  cmake -S . -B build -DSECP256K1_LATE_CFLAGS="-Wno-extra -Wlong-long"
  ```

  ```
  cmake -S . -B build -DSECP256K1_BUILD_EXAMPLES=ON -DSECP256K1_LATE_CFLAGS=-O1
  cmake --build build
  ...
  In function ‘secp256k1_ecmult_strauss_wnaf’,
      inlined from ‘secp256k1_ecmult’ at /home/hebasto/git/secp256k1/src/ecmult_impl.h:353:5:
  /home/hebasto/git/secp256k1/src/ecmult_impl.h:291:5: warning: ‘aux’ may be used uninitialized [-Wmaybe-uninitialized]
    291 |     secp256k1_ge_table_set_globalz(ECMULT_TABLE_SIZE(WINDOW_A) * no, state->pre_a, state->aux);
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /home/hebasto/git/secp256k1/src/secp256k1.c:29:
  /home/hebasto/git/secp256k1/src/ecmult_impl.h: In function ‘secp256k1_ecmult’:
  /home/hebasto/git/secp256k1/src/group_impl.h:174:13: note: by argument 3 of type ‘const secp256k1_fe *’ to ‘secp256k1_ge_table_set_globalz’ declared here
    174 | static void secp256k1_ge_table_set_globalz(size_t len, secp256k1_ge *a, const secp256k1_fe *zr) {
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /home/hebasto/git/secp256k1/src/secp256k1.c:30:
  /home/hebasto/git/secp256k1/src/ecmult_impl.h:345:18: note: ‘aux’ declared here
    345 |     secp256k1_fe aux[ECMULT_TABLE_SIZE(WINDOW_A)];
        |                  ^~~
  ...
  ```

  Please note that in the last case providing `env CFLAGS=-O1` or `-DCMAKE_C_FLAGS=-O1` won't work.

ACKs for top commit:
  real-or-random:
    ACK 42f8c5140227dbdd8ae7eaaecd914e705e1b12d0

Tree-SHA512: 2b152e420a4a8ffd5f67857de03ae5ba9f2223e535ac01a867c1025e0619180d8255fdd1e5fb8279b290f0a1c96bcc874043ef968fcd99b1ff4e13041a91b1e1
2024-01-17 13:20:50 +01:00
Hennadii Stepanov
9f005c60d6
cmake: Install libsecp256k1.pc file
This change allows downstream projects to use pkg-config to search for
the libsecp256k1 library that is built with CMake.
2023-09-07 20:47:57 +01:00
Hennadii Stepanov
c6bb29b303
build: Rename 64bit to x86_64 2023-05-12 10:50:18 +01:00
Hennadii Stepanov
ed4ba238e2
cmake: Add check_arm32_assembly function 2023-05-12 10:38:50 +01:00
Hennadii Stepanov
6ece1507cb
cmake, refactor: Rename try_add_compile_option to try_append_cflags
Actually, `try_append_cflags()` can handle a list of flags, and the new
name is similar to the one used in `configure.ac`.
2023-04-27 14:41:13 +01:00
Hennadii Stepanov
19516ed3e9
cmake: Use add_compile_options() in try_add_compile_option()
This change drops tinkering with the `COMPILE_OPTIONS` directory
property. Also `try_add_compile_option()` can handle a list of flags
now, if they are required to be checked simultaneously.

An explanatory comments have been added as well.
2023-04-27 14:39:10 +01:00
Hennadii Stepanov
42f8c51402
cmake: Add SECP256K1_LATE_CFLAGS configure option 2023-04-26 11:10:03 +01:00
Hennadii Stepanov
6a58b483ef
cmake: Use if(... IN_LIST ...) command
Available in CMake 3.3+.
2023-04-20 17:00:11 +01:00
Hennadii Stepanov
9f8703ef17
cmake: Use dedicated CMAKE_HOST_APPLE variable 2023-04-20 17:00:10 +01:00
Hennadii Stepanov
10602b0030
cmake: Export config files 2023-03-08 13:33:52 +00:00
Hennadii Stepanov
5468d70964
build: Add CMake-based build system
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2023-03-08 13:33:16 +00:00