0

我通过尝试两种安装方式来安装愚蠢。

brew install folly
./build/bootstrap-osx-homebrew.sh

我已验证它已正确安装在该位置/usr/local/Cellar/folly/2017.10.23.00

现在我正在尝试在CLion. 这是我的CMakeLists.txt文件。

cmake_minimum_required(VERSION 3.7)
project(HelloWorld)
message(STATUS "start running cmake....")
set(folly_DIR /usr/local/Cellar/folly/2017.10.23.00)
find_package(Boost 1.66)
find_package(folly 2017.10.23.00)
set(CMAKE_CXX_STANDARD 14)

if(Boost_FOUND)
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")

    include_directories(${Boost_INCLUDE_DIRS})
endif()

if(folly_FOUND)
    message(STATUS "folly_INCLUDE_DIRS: ${folly_INCLUDE_DIRS}")
    message(STATUS "folly_LIBRARIES: ${folly_LIBRARIES}")
    message(STATUS "folly_VERSION: ${folly_VERSION}")

    include_directories(${folly_INCLUDE_DIRS})
endif()

set(SOURCE_FILES main.cpp)
add_executable(HelloWorld ${SOURCE_FILES})

if(Boost_FOUND)
    target_link_libraries(HelloWorld ${Boost_LIBRARIES})
endif()
if(folly_FOUND)
    target_link_libraries(HelloWorld ${folly_LIBRARIES})
endif()

我得到的错误是:

  By not providing "Findfolly.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "folly", but
  CMake did not find one.

  Could not find a package configuration file provided by "folly" (requested
  version 2017.10.23.00) with any of the following names:

    follyConfig.cmake
    folly-config.cmake

  Add the installation prefix of "folly" to CMAKE_PREFIX_PATH or set
  "folly_DIR" to a directory containing one of the above files.  If "folly"
  provides a separate development package or SDK, be sure it has been
  installed.

我设置folly_DIR在顶部,但仍然无法找到。我究竟做错了什么?

4

2 回答 2

1

词组

或将“*_DIR”设置为包含上述文件之一的目录。

在 CMake 错误消息中应被视为将缓存变量设置为适当的值。

-D通常,该变量是在执行时通过命令行选项设置的cmake。如果要在 中设置变量,请在 set 命令中CMakeLists.txt添加CACHE选项:

set(folly_DIR /usr/local/Cellar/folly/2017.10.23.00 CACHE PATH "")

确保给定路径包含错误消息中指出的配置文件之一。

于 2018-02-23T22:10:28.213 回答
0

创建您自己的 FindFolly.cmake 文件如下(参考这里):

# Usage of this module as follows:
#
#     find_package(Folly)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
#  FOLLY_ROOT_DIR Set this variable to the root installation of
#                    folly if the module has problems finding
#                    the proper installation path.
#
# Variables defined by this module:
#
#  FOLLY_FOUND             System has folly libs/headers
#  FOLLY_LIBRARIES         The folly library/libraries
#  FOLLY_INCLUDE_DIR       The location of folly headers

find_path(FOLLY_ROOT_DIR
   NAMES include/folly/folly-config.h
)

find_library(FOLLY_LIBRARIES
   NAMES folly
   HINTS ${FOLLY_ROOT_DIR}/lib
)

find_library(FOLLY_BENCHMARK_LIBRARIES
   NAMES follybenchmark
   HINTS ${FOLLY_ROOT_DIR}/lib
)

find_path(FOLLY_INCLUDE_DIR
   NAMES folly/folly-config.h
   HINTS ${FOLLY_ROOT_DIR}/include
)

include(FindPackageHandleStandardArgs)
   find_package_handle_standard_args(Folly DEFAULT_MSG
   FOLLY_LIBRARIES
   FOLLY_INCLUDE_DIR
)

mark_as_advanced(
   FOLLY_ROOT_DIR
   FOLLY_LIBRARIES
   FOLLY_BENCHMARK_LIBRARIES
   FOLLY_INCLUDE_DIR
)

然后,你需要把这个文件放到你的 CMake 模块路径中(更多细节在这里),这意味着:

  1. 在项目根目录下创建一个名为“cmake/Modules/”的文件夹
  2. 将 FindFolly.cmake 文件放入创建的文件夹中
  3. 将以下行添加到您的 cmake 文件中:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

于 2018-04-16T10:23:14.390 回答