filecoin-project / cpp-filecoin

C++17 implementation of Filecoin
https://filecoin.io/
GNU General Public License v3.0
126 stars 36 forks source link

CMake: Improve building without hunter #601

Closed eigendude closed 2 years ago

eigendude commented 2 years ago

Description of the Change

Now that https://github.com/filecoin-project/cpp-filecoin/pull/128 is merged, I've got Fuhon building without hunter again.

The approach is to delegate finding dependencies to the build system using the typical CMake approach, using find modules. I've included three find modules in this PR.

I only included find modules for three of the dependencies. The reason is because downstream, I just use the hunterized versions of dependencies. However, the hunter team made the unfortunate but easy choice of forking repos. This means that many dependencies have fallen behind the versions used by my team's app. We can't downgrade three of the packages, so I wrote CMake find modules for these three dependencies.

The final patch, for filecoin_ffi, also means that git submodules are no longer needed. This is advantageous, because git submodules cause problems for a fair number of build systems and packagers. And who hasn't forgotten --recursive.

It's an open question if we want CMake find modules for any additional dependencies. I could possibly add this to my List Of Things To Do (tm).

Benefits

Possible Drawbacks

CMake code is added, currently totaling about 70 lines. Normally any lines added increases the load of maintenance, but code that doesn't ship has much less of an impact.

Alternate Designs [optional]

I currently use an alternative approach for the Curl dependency - I just patch out the CONFIG parameter, and ship the patch with the rest of my work. The exact patch is:

commit a136981cfaf04e7fe7f8ced38bcd9ebaf6493f91
Author: Garrett Brown <eigendebugger@gmail.com>
Date:   Tue Feb 15 10:18:31 2022 -0800

    [temp] CMake: Delegate finding CURL to the build system

diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index 6c5636dd..de953113 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -25,8 +25,7 @@ hunter_add_package(OpenSSL)
 find_package(OpenSSL REQUIRED)

 # https://hunter.readthedocs.io/en/latest/packages/pkg/CURL.html#pkg-curl
-hunter_add_package(CURL)
-find_package(CURL CONFIG REQUIRED)
+find_package(CURL REQUIRED)

 # https://developers.google.com/protocol-buffers/
 hunter_add_package(Protobuf)

By not including Curl in this PR, it increases my downstream technical debt, but not significantly.

codecov[bot] commented 2 years ago

Codecov Report

Merging #601 (acae8ac) into master (03fd9bd) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #601   +/-   ##
=======================================
  Coverage   46.02%   46.02%           
=======================================
  Files         715      715           
  Lines       32328    32328           
  Branches    17885    17885           
=======================================
  Hits        14880    14880           
  Misses      13102    13102           
  Partials     4346     4346           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 03fd9bd...acae8ac. Read the comment docs.

Alexey-N-Chernyshov commented 2 years ago

@eigendude, thanks for your interest and cooperation.

eigendude commented 2 years ago

@Alexey-N-Chernyshov thanks for accepting any of the patches. I get crazy ideas like bringing Filecoin to the living room and start to make them. Anything accepted means I don't have to do it twice 🙃