Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake configure fails when using boost asio via find #201

Closed
rcane opened this issue Dec 5, 2023 · 9 comments
Closed

CMake configure fails when using boost asio via find #201

rcane opened this issue Dec 5, 2023 · 9 comments
Milestone

Comments

@rcane
Copy link
Contributor

rcane commented Dec 5, 2023

There are two bugs in the cmake scripts when using boost asio (RESTINIO_ASIO_SOURCE=boost and RESTINIO_DEP_BOOST_ASIO=find).

The first one is this line in the CMakeLists.txt file.
The COMPONENTS part of find_package is only supposed to refer to libraries that are being linked. Since 'headers' is a header-only library it cannot be linked. Having it in the COMPONENTS list will make the cmake configuration fail since there is no target for the 'headers' library.
To fix this just remove the 'headers' reference. The include directory for those header files will already be configured with the find_package(Boost REQUIRED) line.

The second bug is in dev/restinio/cmake/restinio-config.cmake.in where "boost" is misspelled. It should say "Boost" instead.

@eao197
Copy link
Member

eao197 commented Dec 5, 2023

Hi, @rcane !

Thanks for reporting! We'll take a look at them a bit later.

@eao197
Copy link
Member

eao197 commented Dec 5, 2023

I've added a new Dockerfile to check the presence of the first problem on Linux. Unfornunately, this file doesn't show an error with CMake configure.

I'll try to find another way to show that such a problem exists and that it will be fixed properly.

@rcane
Copy link
Contributor Author

rcane commented Dec 5, 2023

Her is some more information that maybe helps:

I encountered the problems when I tried to install restinio via vcpkg.
Since the official vcpkg port uses standalone asio, I created an overlay port where I changed the dependency from "asio" to "boost-asio" and modified the cmake configure parameters in the portfile.cmake to use boost asio. I am doing this under Windows with VS2022.

This SO article got me to the fix of the first bug.

This is the modified configure call I use in the portfile:

vcpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}/dev"
    OPTIONS
        -DRESTINIO_INSTALL=ON
        -DRESTINIO_TEST=OFF
        -DRESTINIO_SAMPLE=OFF
        -DRESTINIO_BENCHMARK=OFF
        -DRESTINIO_WITH_SOBJECTIZER=OFF
        -DRESTINIO_ASIO_SOURCE=boost
        -DRESTINIO_DEP_BOOST_ASIO=find
        -DRESTINIO_DEP_LLHTTP=find
        -DRESTINIO_DEP_FMT=find
        -DRESTINIO_DEP_EXPECTED_LITE=find
)

So it is basically what your are doing in the dockerfile. I have no idea why it does not show the error. Maybe vcpkg does something that makes this different.

@eao197
Copy link
Member

eao197 commented Dec 5, 2023

I'm trying to check that behaviour on Windows with Boost. Maybe it will show the problem.

@ngrodzitski
Copy link
Member

ngrodzitski commented Dec 5, 2023

@eao197
Since v0.7.0 we have boost-asio ci (both system and prebuild=kindly build from sources by @MarkusJx). So I don't think dockerfile is necessary:
Ubuntu-22.04 (gcc-9, Debug, C++17, boost-system-package asio)
Ubuntu-22.04 (gcc-12, Release, C++20, boost asio)

Regarding windows and vcpkg I can take a look tomorrow, and since github runners by default have vcpkg in it we can think of adding a CI (win+vcpk) to avoid such issues future.

@eao197
Copy link
Member

eao197 commented Dec 5, 2023

@ngrodzitski

I had used Dockerfiles before you've configured GitHub CI for v0.7, but the Dockerfile used RESTINIO_DEP_BOOST_ASIO=system. The new file uses RESTINIO_DEP_BOOST_ASIO=find.

I hope I can check Boost on Window today (without vcpkg).

@eao197
Copy link
Member

eao197 commented Dec 5, 2023

It seems that this issue is related to vcpkg. I've tried Boost (1.83.0) on Windows and there are no problems.

I'll try to make a project that uses vcpkg's overlay for RESTinio.

eao197 added a commit that referenced this issue Dec 5, 2023
@eao197
Copy link
Member

eao197 commented Dec 5, 2023

I've repeated this problem with help of https://github.com/Stiffstream/restinio-crud-example/tree/restinio-0.7.0-vcpkg-overlay-boost-asio

There is a fix for the problem in the 0.7-dev-issue-201 branch (at the commit 1f0234d).

I think this fix will be a part of upcoming 0.7.1 release, but I'm afraid this may not happen on this week.

@rcane
Copy link
Contributor Author

rcane commented Dec 5, 2023

Great.
But no rush. Since I already need a port overlay anyway, it was quite easy to patch restinio there and get it working for me.
I am waiting for 0.7.1 to land in vcpkg so I can remove my local patch.

@eao197 eao197 added this to the 0.7.1 milestone Dec 6, 2023
@eao197 eao197 closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants