Linking Facebook Proxygen with Cmake

526 Views Asked by At

Facebook's wangle library can be set up with cmake like below:

set_and_check(WANGLE_INCLUDE_DIR /usr/local/include/wangle)
set_and_check(WANGLE_CMAKE_DIR /usr/local/lib/cmake/wangle)

if (NOT TARGET wangle::wangle)
    include("${WANGLE_CMAKE_DIR}/wangle-targets.cmake")
endif()

set(WANGLE_LIBRARIES wangle::wangle)

if (NOT wangle_FIND_QUIETLY)
    message(STATUS "Found wangle: ${PACKAGE_PREFIX_DIR}")
endif()

However, proxygen's install.sh doesn't put the include and lib files in /usr/local like wangle and other fb libraries do.

What is the proper way to set the include and link with proxygen via cmake?

1

There are 1 best solutions below

2
On

According to the proxygen README you should install all requirements, including folly, wangle, fmt, fizz, and mvfst if you need HTTP/3 protocol. After installing proxygen with the instruction in the README you can use it in your CMake project. Following is an example CMakeLists.txt and you can find the complete sample project in this repo.

cmake_minimum_required(VERSION 3.10)

project(3hat)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

find_package(proxygen REQUIRED)
find_package(gflags REQUIRED)
  
add_subdirectory(server)