首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Folly项目的Cmake文件

Folly项目的Cmake文件
EN

Stack Overflow用户
提问于 2019-06-09 11:15:35
回答 1查看 1.4K关注 0票数 2

我正在尝试写一个使用Facebook的Folly library的玩具示例。该程序包含以下内容:

代码语言:javascript
复制
#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文件,我将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-11 02:23:16

下面是创建Folly项目所需的CMakeLists.txt

代码语言:javascript
复制
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})
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56511716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档