c++ - Folly 项目的 Cmake 文件

标签 c++ folly

我正在尝试编写一个玩具示例来使用 Facebook 的 Folly library .程序引入如下:

#include <utility>
#include <iostream>
#include <folly/Format.h>
#include <folly/futures/Future.h>
#include <folly/executors/ThreadedExecutor.h>
#include <folly/Uri.h>
#include <folly/FBString.h>

static void print_uri(const folly::fbstring &address)
{
  const folly::Uri uri(address);
  const auto authority = folly::format("The authority from {} is {}", uri.fbstr(), uri.authority());
  std::cout << authority << std::endl;
}

int main()
{
  folly::ThreadedExecutor executor;
  folly::Promise<folly::fbstring> promise;
  folly::Future<folly::fbstring> future = promise.getSemiFuture().via(&executor);
  folly::Future<folly::Unit> unit = std::move(future).thenValue(print_uri);
  promise.setValue("https://conan.io/");
  std::move(unit).get();
  return 0;
}

问题是我不确定编译这样的程序需要哪些库。如果有人可以共享 Folly 项目的 CMakeList.txt 文件,我将不胜感激。

最佳答案

这是制作Folly 项目所需的CMakeLists.txt

cmake_minimum_required(VERSION 3.7)
find_package(Boost REQUIRED)
find_package(folly REQUIRED)
find_package(Threads REQUIRED)
find_package(gflags REQUIRED)

set(CMAKE_CXX_STANDARD 14)
#include_directories(${Boost_INCLUDE_DIRS})
#include_directories(${folly_INCLUDE_DIRS})

set_and_check(FOLLY_INCLUDE_DIR /usr/local/include/folly)
set_and_check(FOLLY_CMAKE_DIR /usr/local/lib/cmake/folly)
if (NOT TARGET Folly::folly)
  include("${FOLLY_CMAKE_DIR}/folly-targets.cmake")
endif()


set(FOLLY_LIBRARIES Folly::folly)

if (NOT folly_FIND_QUIETLY)
  message(STATUS "Found folly: ${PACKAGE_PREFIX_DIR}")
endif()

add_executable(HelloWorld main.cpp)
target_link_libraries(HelloWorld ${Boost_LIBRARIES} ${FOLLY_LIBRARIES})

关于c++ - Folly 项目的 Cmake 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56511716/

相关文章:

c++ - 如何使用特定类型的折叠表达式?

c++ - 返回时复制操作是在 lock_guard 析构函数之前还是之后执行的?

c++ - 如何使用 msxml 解析器创建子元素?

c++11 - 递归变量声明

c++ - Facebook 的愚蠢行为中的大端和小端

c++ - 没有运算符 << 匹配这些操作数

c++ - 在编译时打印模板类型名

c++ - 前循环迭代对当前迭代执行时间的影响

c++ - 链接到 jemalloc 的 SDL2 程序在 Mac os x 但不是 ubuntu 上崩溃