Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Use SECP256K1_COVERAGE option instead of CMAKE_BUILD_TYPE=Coverage #1291

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Apr 29, 2023

Providing -DCMAKE_BUILD_TYPE=Coverage does not work for multi-config generators.

For example:

$ cmake -S . -B ../build -G "Ninja Multi-Config"
$ cmake --build ../build -C Coverage

still builds the tests binary.

This PR:

The last commit addresses that comment.

@hebasto
Copy link
Member Author

hebasto commented Jun 1, 2023

Friendly ping @theuni :)

@theuni
Copy link
Contributor

theuni commented Jun 23, 2023

Sorry for the missed ping.

Concept ACK as discussed in Dublin. Will review next week.

@hebasto
Copy link
Member Author

hebasto commented Jul 2, 2023

Rebased.

hebasto added a commit to hebasto/bitcoin that referenced this pull request Sep 13, 2023
a65da0d cmake: Redefine configuration flags (Hennadii Stepanov)
1a1dda5 [FIXUP] Evaluate flags set in depends _after_ config-specific flags (Hennadii Stepanov)
482e844 cmake: Warn about not encapsulated build properties (Hennadii Stepanov)
3736470 cmake: Add platform-specific flags (Hennadii Stepanov)
e0621e9 cmake: Add `TryAppendLinkerFlag` module (Hennadii Stepanov)
ae430cf cmake: Add `TryAppendCXXFlags` module (Hennadii Stepanov)
7903bd5 [FIXUP] Encapsulate common build flags into `core` interface library (Hennadii Stepanov)

Pull request description:

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10, #13, #15, #17, #19.

  ---

  What is NEW:
  - functions for checking compiler and linker flags
  - managing flags for different build types (configurations)

  EXAMPLES of configuration output on Ubuntu 22.04:

  -  for a single-config generator:
  ```
  $ cmake .. -G "Unix Makefiles"
  ...
  Cross compiling ....................... FALSE
  Preprocessor defined macros ...........
  C compiler ............................ /usr/bin/cc
  CFLAGS ................................
  C++ compiler .......................... /usr/bin/c++
  CXXFLAGS ..............................
  Common compile options ................
  Common link options ...................
  Linker flags for executables ..........
  Linker flags for shared libraries .....
  Build type (configuration):
   - CMAKE_BUILD_TYPE ................... RelWithDebInfo
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2 -g
   - CXXFLAGS ........................... -O2 -g
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  - for a multi-config generator:
  ```
  $ cmake .. -G "Ninja Multi-Config"
  ...
  Cross compiling ....................... FALSE
  Preprocessor defined macros ...........
  C compiler ............................ /usr/bin/cc
  CFLAGS ................................
  C++ compiler .......................... /usr/bin/c++
  CXXFLAGS ..............................
  Common compile options ................
  Common link options ...................
  Linker flags for executables ..........
  Linker flags for shared libraries .....
  Available build types (configurations)  RelWithDebInfo Debug Release
  'RelWithDebInfo' build type (configuration):
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2 -g
   - CXXFLAGS ........................... -O2 -g
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  'Debug' build type (configuration):
   - Preprocessor defined macros ........ DEBUG DEBUG_LOCKORDER DEBUG_LOCKCONTENTION RPC_DOC_CHECK ABORT_ON_FAILED_ASSUME
   - CFLAGS ............................. -O0 -g3
   - CXXFLAGS ........................... -O0 -g3 -ftrapv
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  'Release' build type (configuration):
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2
   - CXXFLAGS ........................... -O2
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  - cross-compiling for Windows:
  ```
  $ make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 NO_QT=1
  $ cmake -B build --toolchain depends/x86_64-w64-mingw32/share/toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
  ...
  Cross compiling ....................... TRUE, for Windows, x86_64
  Preprocessor defined macros ........... _WIN32_WINNT=0x0601 _WIN32_IE=0x0501 WIN32_LEAN_AND_MEAN NOMINMAX WIN32 _WINDOWS _MT _GLIBCXX_DEBUG _GLIBCXX_DEBUG_PEDANTIC
  C compiler ............................ /usr/bin/x86_64-w64-mingw32-gcc
  CFLAGS ................................ -pipe -std=c11 -O1
  C++ compiler .......................... /usr/bin/x86_64-w64-mingw32-g++-posix
  CXXFLAGS .............................. -pipe -std=c++17 -O1
  Common compile options ................
  Common link options ................... -Wl,--major-subsystem-version,6 -Wl,--minor-subsystem-version,1
  Linker flags for executables .......... -static
  Linker flags for shared libraries .....
  Build type (configuration):
   - CMAKE_BUILD_TYPE ................... Debug
   - Preprocessor defined macros ........ DEBUG DEBUG_LOCKORDER DEBUG_LOCKCONTENTION RPC_DOC_CHECK ABORT_ON_FAILED_ASSUME
   - CFLAGS ............................. -O0 -g3
   - CXXFLAGS ........................... -O0 -g3 -ftrapv
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  **A cross-project note.** The `ProcessConfigurations.cmake` is based on the same module that was suggested in bitcoin-core/secp256k1#1291. So, cross-reviewing is welcome :)

ACKs for top commit:
  theuni:
    ACK a65da0d to keep this moving. This has been sitting for too long :(

Tree-SHA512: 57c5e91ddf9675c6a2b56c0cb70fd3f045af8076bee74c49390de38b8d514e130d2086fde6d83d2d1278b437d0a10cc721f0aa44934698110aeadb3a1aef9e64
@hebasto hebasto marked this pull request as draft May 7, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants