cmake: Do not modify build types when integrating by downstream project #1543

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:240618-cmake-conf changing 1 files +17 −15
  1. hebasto commented at 2:52 PM on June 18, 2024: member

    The CMAKE_BUILD_TYPE and CMAKE_CONFIGURATION_TYPES must be managed by the downstream project.

    Suggesting to review with git diff -w.

    Fixes std::out_of_range exception from CMake in https://github.com/hebasto/bitcoin/pull/192 when running configuration step using "Ninja Multi-Config" generator:

    $ cmake -B build -G "Ninja Multi-Config"
    ...
    -- Configuring done (17.1s)
    terminate called after throwing an instance of 'std::out_of_range'
      what():  map::at
    Aborted (core dumped)
    

    Here are related discussions:

  2. cmake: Do not modify build types when integrating by downstream project
    The `CMAKE_BUILD_TYPE` and `CMAKE_CONFIGURATION_TYPES` variables must be
    managed by the downstream project.
    
    Suggesting to review with `git diff -w`.
    158f9e5eae
  3. fanquake commented at 3:36 PM on June 18, 2024: member

    Fixes std::out_of_range exception in https://github.com/hebasto/bitcoin/pull/192 when using "Ninja Multi-Config" generator.

    Can you at least elaborate some amount? How is changing something CMake related in this C project, the solution to some C++ issue in a different project? Theres no details or CI failure etc in the linked PR, so it's not even clear what's broken there.

  4. real-or-random commented at 8:12 PM on June 18, 2024: contributor

    Yeah, I tend to agree that we shouldn't touch these variables. But it's a bit unclear how this fixes a std::out_of_range exception.

  5. real-or-random added the label bug on Jun 18, 2024
  6. real-or-random added the label build on Jun 18, 2024
  7. real-or-random commented at 8:28 PM on June 18, 2024: contributor

    Yeah, I tend to agree that we shouldn't touch these variables.

    Hm, on a second thought, I'm not sure. I believe we want to build libsecp256k1 with the default RelWithDebInfo (-O2 -g in our case) even when we build it as part of Core. Because (almost) all our testing uses this config.

    edit: What does the current autotools build do?


    By the way, this is one of these issues that makes me wonder if the GNU build system was actually that bad. The amount of "custom" logic that is needed to convince CMake to do the right thing is still large.

  8. fanquake commented at 10:54 AM on June 20, 2024: member

    How is changing something CMake related in this C project, the solution to some C++ issue in a different project?

    After offline discussion, it's been clarified that the std::out_of_range exception is actually coming from CMake itself, with it being uncertain as to whether the CMake developers consider it a bug or just "misuse". @hebasto if you have a link to upstream discussion, it'd be good to have it here as well.

  9. hebasto commented at 10:57 AM on June 20, 2024: member

    Fixes std::out_of_range exception in hebasto/bitcoin#192 when using "Ninja Multi-Config" generator.

    Can you at least elaborate some amount? How is changing something CMake related in this C project, the solution to some C++ issue in a different project? Theres no details or CI failure etc in the linked PR, so it's not even clear what's broken there.

    I've updated the PR description trying to make it more descriptive and providing more details.

    @hebasto if you have a link to upstream discussion, it'd be good to have it here as well.

    Done.

  10. real-or-random commented at 11:14 AM on June 20, 2024: contributor

    I've updated the PR description trying to make it more descriptive and providing more details.

    @hebasto if you have a link to upstream discussion, it'd be good to have it here as well.

    Done.

    There's also an GitLab issue now: https://gitlab.kitware.com/cmake/cmake/-/issues/26064. I took the freedom to add the link to the PR description.

  11. hebasto commented at 5:54 PM on June 24, 2024: member

    The CMake's bug has been fixed in https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9618.

    I tested CMake version 3.30.0-rc4 and no exceptions happen.

    Nevertheless, this PR's changes are still meaningful and required.

  12. real-or-random approved
  13. real-or-random commented at 6:07 PM on June 24, 2024: contributor

    ACK 158f9e5eae583b1520af9ee727db342e7408dab1

  14. fanquake commented at 8:57 AM on June 25, 2024: member

    Tested that this change (combined with https://github.com/hebasto/bitcoin/pull/192) no-longers results in CMake segfaulting when configuring. I assume there's nothing else we need to do, even if CMake also changes its docs here: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9618#note_1538910 ?

  15. real-or-random commented at 9:28 AM on June 25, 2024: contributor

    The CMAKE_BUILD_TYPE and CMAKE_CONFIGURATION_TYPES must be managed by the downstream project.

    All the CMake issues mention only CMAKE_CONFIGURATION_TYPES? Have you a reference for the claim that also CMAKE_BUILD_TYPE should be managed by the top-level project? (Well, it's probably also just a good idea for consistency?)

  16. hebasto commented at 10:19 AM on June 25, 2024: member

    The CMAKE_BUILD_TYPE and CMAKE_CONFIGURATION_TYPES must be managed by the downstream project.

    All the CMake issues mention only CMAKE_CONFIGURATION_TYPES? Have you a reference for the claim that also CMAKE_BUILD_TYPE should be managed by the top-level project? (Well, it's probably also just a good idea for consistency?)

    The CMAKE_BUILD_TYPE being a cache variable is dedicated to be modifiable externally and it should be managed by the top-level project for consistency.

    The same technique is suggested in the book Professional CMake: A Practical Guide, section 15.3. Custom Build Types.

  17. real-or-random merged this on Jun 25, 2024
  18. real-or-random closed this on Jun 25, 2024

  19. hebasto deleted the branch on Jun 25, 2024
  20. fanquake referenced this in commit b941c15808 on Jun 25, 2024
  21. hebasto referenced this in commit b20389c74a on Jun 25, 2024
  22. fanquake referenced this in commit 1408944d2e on Jun 25, 2024
  23. achow101 referenced this in commit 9ac4f69ec2 on Jun 26, 2024
  24. vmta referenced this in commit bafdd96c0a on Jul 3, 2024
  25. janus referenced this in commit 411aef6677 on Jul 26, 2024
  26. vmta referenced this in commit 871c80c433 on Sep 6, 2024
  27. vmta referenced this in commit 4d1f6d5635 on Oct 29, 2024
  28. div72 referenced this in commit af627d47c3 on Apr 12, 2025
  29. oskarszoon referenced this in commit 0d5c9260f4 on Jul 1, 2025
  30. real-or-random referenced this in commit 4ae7cb4f71 on Feb 11, 2026
  31. github-actions[bot] referenced this in commit 758d4e90b4 on Mar 1, 2026
  32. github-actions[bot] referenced this in commit 68a2178f22 on Mar 1, 2026
  33. github-actions[bot] referenced this in commit a8bc1a0b2b on Mar 1, 2026
  34. 0x000000000019d6689c085ae165831e934ff76 referenced this in commit 3b9450150d on Mar 2, 2026
  35. csjones referenced this in commit a4d92824ae on Mar 2, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC