Skip to content

cmake: Fix build with depends on NixOS#126

Closed
hebasto wants to merge 93 commits into
cmake-stagingfrom
240323-cmake-CR
Closed

cmake: Fix build with depends on NixOS#126
hebasto wants to merge 93 commits into
cmake-stagingfrom
240323-cmake-CR

Conversation

@hebasto
Copy link
Copy Markdown
Owner

@hebasto hebasto commented Mar 23, 2024

Define depends prefix relatively to the toolchain file location (the same way as it is done for the config.site file on the master branch).

Should fix building on NixOS with depends (see #121).

hebasto and others added 30 commits March 8, 2024 13:33
Also add a sanity check for non-encapsulated (directory-wide) build
properties.
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com>
To configure CMake for cross-compiling, use
`--toolchain depends/${HOST}/share/toolchain.cmake` command-line option.
hebasto added 15 commits March 13, 2024 11:49
e4b4c98 fixup! cmake: Migrate Guix build scripts to CMake (Hennadii Stepanov)
0be2225 cmake: Build `test_bitcoin-qt` executable (Hennadii Stepanov)
4da7634 fixup! cmake: Build `bitcoin-qt` executable (Hennadii Stepanov)

Pull request description:

  A new configuration option is `BUILD_GUI_TESTS`.

  ---

  **Native Windows / MSVC Notes:**
  1. vcpkg configures Qt with `-opengl dynamic`, which makes the "minimal" platform plugin unusable due to internal Qt bugs.
  2. `ctest` workarounds this issue by setting the environment variable `QT_QPA_PLATFORM=windows`.
  3. This approach works nice in the CI for both `x64-windows` and `x64-windows-static` triplets. Please note that `test_bitcoin-qt.exe` fails to run in the CI environment on the master branch.
  4. One who is willing to debug Qt with the "minimal" platform plugin could run the `test_bitcoin-qt.exe` directly (not driven by `ctest`).

ACKs for top commit:
  pablomartin4btc:
    re tACK e4b4c98

Tree-SHA512: 638de710aa722a168b9944089062b2da43f9f14cb0684acb8fc5922907e96b1e4d8c04c852826275d5cbbbd824a1f2905d550bdf5355cef9f22738414e7fbd6e
593b130 cmake: Add `libqrencode` optional package support (Hennadii Stepanov)

Pull request description:

  A new configuration option `WITH_QRENCODE` has been added.

  This PR, along with #101, concludes the GUI-specific part of the new CMake-based build system.

ACKs for top commit:
  pablomartin4btc:
    tACK 593b130

Tree-SHA512: ba21d65ccff59e29585bd6ce092216034abcbd9866e5452fe6a1b1e2f0957dc3c48a204c170ce443888852ae165be7cb1846483b031b8cf49e6d986dec722f88
Set `CCACHE_COMPILERCHECK` to avoid false cache invalidating.
Add docstrings for options when cross-compiling.
326d0f7 fixup! ci: Test CMake edge cases (Hennadii Stepanov)

Pull request description:

  For the recent two consequential CI runs:
  - https://github.com/hebasto/bitcoin/actions/runs/8263699604 and
  - https://github.com/hebasto/bitcoin/actions/runs/8264179478

  I've noticed a [pure Ccache performance](https://github.com/hebasto/bitcoin/actions/runs/8264179478/job/22607226576) for the "macOS 13 native, x86_64, Xcode 14.3" job:
  ```
  Cacheable calls:     634 / 634 (100.0%)
    Hits:                0 / 634 ( 0.00%)
  ```

  This PR sets `CCACHE_COMPILERCHECK=%compiler% -v` for macOS jobs to avoid false cache invalidating.

  The other option, i.e., `content`, has been tried as well in my experiments, but it also has cache performance issues.

ACKs for top commit:
  pablomartin4btc:
    utACK 326d0f7

Tree-SHA512: 2c01dca0699b788341de0bd7436a6c6664dce189e3604b894d5ebe60d0267d49911949c3ee2eb8b3095b03a94773830a4840dfb3592628c55314009dd39170e8
33a454e fixup! cmake: Check system symbols (Hennadii Stepanov)
3cb2e65 fixup! cmake: Check system headers (Hennadii Stepanov)

Pull request description:

  This PR backports build system changes from bitcoin#29263.

ACKs for top commit:
  pablomartin4btc:
    ACK 33a454e

Tree-SHA512: 1793c6504a7190134c0ce075e959d22c4a3640d54a4d141f5117975bed267952cc8c7da488426e48022eba1eb77d3353783d77a20907b0cfa183e0b68d824133
dc1a121 fixup! cmake: Check compiler features (Hennadii Stepanov)

Pull request description:

  This PR backports build system changes from bitcoin#29484.

ACKs for top commit:
  pablomartin4btc:
    ACK dc1a121

Tree-SHA512: e6005f96a9632fb4787d2dcfc558aa484be6401804ffcdfe68e6d17e39576d7fc55cbf17f0c7097f32c4639201f6b26c7098bb9a1cce801fee6bd77047cfa82d
840e494 fixup! build: Generate `share/toolchain.cmake` in depends (Hennadii Stepanov)

Pull request description:

  See discussion in #118 (comment).

  Can be tested in the following ways:
  - applying the `-LH` command line option
  - using `cmake-gui`
  - direct observing of the `CMakeCache.txt` file content

ACKs for top commit:
  pablomartin4btc:
    tACK 840e494

Tree-SHA512: fd441457dc4df44b54c5fe98119786126db6b592f58ce7bca642a65921ffb9572d0e2afca07471666f425b647ef69f860228b8a0d61d02468d41edccad25627b
Bump CMake minimum required version up to 3.22
CMake 3.19:
- The CMAKE_<LANG>_COMPILER variable may now be used to store
"mandatory" compiler flags like the CC and other environment variables.

CMake 3.21:
- The Makefile Generators and the Ninja generator learned to add linker
launcher tools along with the linker for C, CXX, OBJC, and OBJCXX
languages.
CMake 3.17:
- The FindPkgConfig module now extracts include directories prefixed
with -isystem into the *_INCLUDE_DIRS variables and
INTERFACE_INCLUDE_DIRECTORIES target properties.
CMake 3.20:
- The configure_file() command gained FILE_PERMISSIONS options to
support using specified permissions.
CMake 3.17:
- The CMAKE_CURRENT_FUNCTION variable is now defined inside a
function().
CMake 3.21:
- cmake gained the --toolchain command-line option to specify a
toolchain file.
@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented Mar 23, 2024

cc @0xB10C

Define depends prefix relatively to the toolchain file location (the
same way it is done for the `config.site` file).

Should fix building on NixOS.
@0xB10C
Copy link
Copy Markdown

0xB10C commented Mar 25, 2024

I can confirm that a NixOS depends build as I'm doing in https://github.com/0xB10C/bitcoind-gunix now works with this PR without having to set env variables manually. I needed -DCMAKE_PREFIX_PATH=/ before. However, I'm not able to comment on all cmake changes here.

See: 0xB10C/bitcoind-gunix#3 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants