HomePhabricator

[CMAKE] Improve FindBerkeleyDB

Description

[CMAKE] Improve FindBerkeleyDB

Summary:
This diff refactors the FindBerkeleyDB.cmake module and improve it in
several ways:

  • It follows the cmake best practices on variable names;
  • It extracts a version number from the db.h header so a minimal version can be required (previously any version would match);
  • It creates an imported target that can be linked to propagate usage requirements (no longer needed to use the list variables);
  • It provides a best-effort path search to find the header and libraries, by combining around the version number (more future-proof);
  • It provides useful messages when the files are found;
  • It marks the cache variables as advanced to make it GUI friendly.

This is expected to serve as a reference to update the other FindPackage
modules in the same manner.

Test Plan:

cmake -GNinja ..

Check in the output for lines similar to:

-- Found BerkeleyDB: /usr/include (found suitable version "5.3.28",
minimum required is "5.3")
-- Found BerkeleyDB libraries:
/usr/lib/x86_64-linux-gnu/libdb.so;/usr/lib/x86_64-linux-gnu/libdb_cxx.so
ninja all check

Run the Gitian builds.

Edit the src/wallet/CMakeLists.txt and change the minimum version to
19.42.

cmake -GNinja ..

Check that cmake fails to find the lib and complains with a meaningful
error message similar to:

Could NOT find BerkeleyDB: Found unsuitable version "5.3.28", but
required is at least "19.42" (found /usr/include)

Reviewers: #bitcoin_abc, jasonbcox, deadalnix

Reviewed By: #bitcoin_abc, jasonbcox, deadalnix

Subscribers: deadalnix, jasonbcox

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

Details

Provenance
FabienAuthored on Feb 21 2020, 19:03
FabienPushed on Mar 7 2020, 09:34
Reviewer
Restricted Project
Differential Revision
D5339: [CMAKE] Improve FindBerkeleyDB
Parents
rABC2502e221aae2: Move PackageOptions out of cmake/modules
Branches
Unknown
Tags
Unknown