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

Using a standalone asio for crow with CPM #962

Open
rhvarrier opened this issue Dec 18, 2024 · 1 comment
Open

Using a standalone asio for crow with CPM #962

rhvarrier opened this issue Dec 18, 2024 · 1 comment
Labels
question Issue can be closed by providing information

Comments

@rhvarrier
Copy link

Hello all

I want to build a standalone app using CPM to manage the dependecies. I see that Crow depends on asio and it seems that it I need to install libasio-dev in order use Crow.

There a way to force Crow to use a version of asio that I downloded using CPM. I see that in Crow Cmake file, there is a find_package for asio and that there is Findasio.cmake that does the follwing find_path(ASIO_INCLUDE_DIR asio.hpp)

I tried setting asio_ROOT as suggested by the cmake documentation

cmake_minimum_required(VERSION 3.20)

project(app VERSION 0.1 LANGUAGES CXX)

include(cmake/get_cpm.cmake)

find_package(Threads REQUIRED)
CPMAddPackage("gh:chriskohlhoff/asio#asio-1-32-0@1.32.0")

if(asio_ADDED)
  set(asio_ROOT ${asio_SOURCE_DIR}/asio/include)
  CPMAddPackage(Crow
  VERSION 1.2.0
  GITHUB_REPOSITORY CrowCpp/Crow
  OPTIONS
  "CROW_BUILD_EXAMPLES Off"
  "CROW_BUILD_TOOLS Off"
  "CROW_BUILD_TESTS Off"
  "CROW_BUILD_DOCS Off"
  "CROW_ENABLE_COMPRESSION Off"
  "CROW_ENABLE_SSL Off"
)
else()
  message(ERROR "Asio not found")
endif()

set(BIN_OUT app)
file(
     GLOB_RECURSE
     SRCS
     src/*
    )
add_executable(${BIN_OUT} ${SRCS})
target_link_libraries(${BIN_OUT} 
                      Crow::Crow)

But it does not work.

Is there a way to override this so that I can pass a path where asio is installed

@gittiver gittiver added the question Issue can be closed by providing information label Dec 21, 2024
@debugmenot
Copy link

debugmenot commented Dec 22, 2024

its not required to actually install asio as a package. you can just download tgz, unpack it to build/_deps or someehere else and specify the path to asio include dir:

CPMAddPackage(
    GITHUB_REPOSITORY CrowCpp/Crow
    GIT_TAG v1.2.0 
    OPTIONS
        BUILD_SHARED_LIBS=OFF
        ASIO_INCLUDE_DIR=/usr/local/include # or ${ASIO_INCLUDE_DIR} that is valid after asio standalone tgz unpacking
)

and seems the problem is not there. Use asio with tag asio-1-30-2. Crowcpp for now is not compatible with latest asio build because of asio::io_service deprecation (should be replaced to asio::io_context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue can be closed by providing information
Projects
None yet
Development

No branches or pull requests

3 participants