0

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?

codepro
  • 283
  • 3
  • 8
  • 1
    The file you show is `wangle-config.cmake` config script which is **generated** (from [wangle/cmake/wangle-config.cmake.in](https://github.com/facebook/wangle/blob/master/wangle/cmake/wangle-config.cmake.in)) for a **specific** package installation. Other installations should come with their own `wangle-config.cmake` script. For use other installations you need to tell CMake to use corresponding script. You may do that e.g. by passing `-Dwangle_DIR=` parameter to `cmake`. – Tsyvarev Jul 17 '20 at 07:13
  • Recent version of proxygen install proxygen-config.cmake in /usr/local/lib/cmake and you can use it in your CMakeLists.txt. – Ali Shirvani Feb 02 '21 at 08:51
  • How do you make use of it in my CMakeLists.txt @AliShirvani – Luke May 04 '21 at 23:43

1 Answers1

1

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)
Ali Shirvani
  • 533
  • 6
  • 15
  • Never _ever_ set an absolute path in your CMakeLists.txt file and don't overwrite `CMAKE_MODULE_PATH` there, either. You can _append_, however. – Alex Reinking May 05 '21 at 00:04
  • Can you give an example of how it should be done correctly @AlexReinking? Also is it possible to link to proxygen without installing it? – Luke May 05 '21 at 03:45