Stiffstream / restinio

Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.15k stars 93 forks source link

restinio-0.7.2-full.zip could not be used as CMake external project, in fact it is only suitable for add_subdirectory() to your project #221

Open Trotzky opened 2 months ago

Trotzky commented 2 months ago

restinio-0.7.2-full.zip cannot be used as a separate(external) project because it does not install all it's locally provided dependencies. Also to find shipped asio manual setting of CMAKE_MODULE_PATH is needed to provide path to Findasio.cmake module. But this does not saves the day because llhttp::llhttp_static and nonstd::expected-lite still missing and according to restinio-config.cmake we don't use find_dependency() on them because they are "local".

When llhttp and expected-lite is set to local, Restinio adds them to itself using add_subdirectory() but they are not being installed as part of restinio installation step, so later in other project doing find_package(restinio REQUIRED) we got this:

CMake Error at CMakeLists.txt:61 (find_package):
  -- Configuring incomplete, errors occurred!
    Found package configuration file:

      D:/Projects/proj/build/local_deps/lib/cmake/restinio/restinio-config.cmake

    but it set restinio_FOUND to FALSE so package "restinio" is considered to
    be NOT FOUND.  Reason given by package:

    The following imported targets are referenced, but are missing:
    llhttp::llhttp_static nonstd::expected-lite

Possibly local fmt will have similar problems. I am using external fmt with RESTINIO_DEP_FMT == 'find' and it's ok.

Resolving this issue will requre significant amount of build system refactoring. I think we need to use Superbuild pattern here. Just build all dependencies one by one as a separate projectd and install them. Restinio should use them via find_dependency() and add them to Restinio lib target, so any target using Restinio will know about all dependencies.

It will be great to see future Restinio release with this issues resolved!

eao197 commented 2 months ago

Hi! Thanks for reporting.

restinio-0.7.2-full.* archives are added to simplify experiments with RESTinio for those who wants to run some of RESTinio's examples or/and tests. These archives are not intended to be used as RESTinio's distribution (for tools like CMake's fetch_content).

When RESTinio performs install operation it doesn't installs dependencies by design. If someone follows Unix-inspired approach where a library is installed somewhere after a successful build, then he/she has to use the same approach for RESTinio's dependencies. So it's not a bug, it's a feature.