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.16k stars 93 forks source link

Question: Can I use Restinio with fetchContent #141

Closed noctera closed 3 years ago

noctera commented 3 years ago

I'm wondering if I could use the restinio lib with cmakes' fetchContent functionality.

I have tried it with

FetchContent_Declare(restinio GIT_REPOSITORY https://github.com/Stiffstream/restinio)
FetchContent_MakeAvailable(restinio)
target_link_libraries(myProject LINK_PUBLIC restinio::restinio)

But it didn't work. I think there isn't any fetchContent support, is it?

eao197 commented 3 years ago

Hi!

I don't think that FetchContent requires some support on the side of an external project. Its purpose is to get any external project and add its content to your build tree. So I think you have to study the usage of FetchContent more deeply. It seems there are various options for FetchContent that allows you to deal with RESTinio's directory structure/ For example, the RESTinio's root doesn't have CMakeLists.txt, the top-level CMakeLists.txt is in dev subdirectory. So the FetchContent_Declare may look like:

FetchContent_Declare(restinio
  GIT_REPOSITORY https://github.com/Stiffstream/restinio
  SOURCE_SUBDIR dev
)

You may also have set appropriate values for variables like restinio_TEST, restinio_SAMPLE, restinio_INSTALL_SAMPLES, and so on.

Please also note that RESTinio doesn't contain some important dependencies (like http-parser and fmtlib) inside the git-repo, so you have to fetch those dependencies by yourself.

PS. We don't use CMake for the development of RESTinio, CMake support is provided only for the convenience of users. We aren't experts in CMake.

noctera commented 3 years ago

I'm using restinio lib with Conan now. Works perfekt and there are no problems with installation and linking.