fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

Examples are out of touch with reality and documentation #95

Closed kusosuha6vt closed 3 months ago

kusosuha6vt commented 5 months ago

For example, sockpp/examples/tcp/tcpecho.cpp doesn't compile, because tcp_connector expects addr_t instead of address and port. And documentation doesn't say how to construct an addr_t

fpagliughi commented 5 months ago

Which version are you trying?

MasFlam commented 3 months ago

This is the case at least for 1.0.0. At the commit tagged for that release on branch v1.x, the repository for example doesn't have the sockpp/version.h header file, which the examples include.

Edit:

I'm wrong. Actually, that header is generated and the examples do compile. It seems the problem (for me) is that using sockpp through FetchContent doesn't result in build/generated/include being added to the PUBLIC include directories of the sockpp target. What is the reasoning behind it being added as PRIVATE in CMakeLists.txt anyway?

https://github.com/fpagliughi/sockpp/blob/4a0d8e087452b5c74179b268c0aceadef90906b9/CMakeLists.txt#L106-L112

On that note, is it even a good idea to use FetchContent? What would be the preferred way to use sockpp from a CMake project?

fpagliughi commented 3 months ago

I'm not a CMake power user. I'm just figuring it out a little as I go along. I've never heard of FetchContent.

The two common ways to use a library like this from your own CMake project:

  1. Download the source, then build and install it. After that, use it like any other system library package: use FindPackage or just link the library.
  2. Copy the source to a subdirectory of your project (usually as a Git submodule) then include it in your build with add_subdirectory().

My initial assumption was 1, and that is basically what is documented in the README. Download the sources, go to the top-level source directory and enter:

$ cmake --build build/ --target install

That installs the built library onto your system. Then in your CMake,

find_package(sockpp REQUIRED)
...
target_link_libraries(myapp Sockpp::sockpp)

At some point I can verify that 2 works and add instructions for that.

fpagliughi commented 3 months ago

Closing this as we have gone off-topic from the original issue. Please re-open if there is a specific repo branch or release version which has a broken build for the examples.