macos - cmake find_package 在 Mac OS X 上不工作

标签 macos cmake gsl

只是尝试创建我的第一个 cmake 项目。我有一个非常简单的设置,但似乎无法让 find_package 工作。我在 Mac OS X 10.9.3 上安装了 dmg 包中的 cmake(cmake 版本 2.8.12.2)。我创建了一个非常简单的 CMakeLists.txt,如下所示:

cmake_minimum_required (VERSION 2.8)
project (Tutorial)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} “${CMAKE_SOURCE_DIR}/cmake/Modules”)
message( STATUS ${CMAKE_MODULE_PATH} )
FIND_PACKAGE(GSL REQUIRED)

add_executable(Tutorial src/main.cpp)

并将 FindGSL.cmake 文件(已下载)放置在 cmake/Module 文件夹中,如我的终端输出所示:

bash-3.2$ ls cmake/Modules/
FindGSL.cmake

然后我从 cmake 得到以下输出:

bash-3.2$ cmake ../
-- “/Users/adam/repos/ctmc/cmake/Modules”
CMake Error at CMakeLists.txt:6 (FIND_PACKAGE):
  By not providing "FindGSL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "GSL", but
  CMake did not find one.

  Could not find a package configuration file provided by "GSL" with any of
  the following names:

    GSLConfig.cmake
    gsl-config.cmake

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


-- Configuring incomplete, errors occurred!
See also "/Users/adam/repos/ctmc/build/CMakeFiles/CMakeOutput.log".

谁能指出我做错了什么?

最佳答案

检查您的 cmake/Modules 目录权限。您没有 execute 权限 目录,因此如果您有文件的完整路径,则您可以读取文件,但找不到它:

> ls cmake/Modules/FindMy.cmake 
cmake/Modules/FindMy.cmake
> cat CMakeLists.txt 
cmake_minimum_required(VERSION 3.0)
project(Foo)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
find_package(My REQUIRED)
> cmake -H. -B_builds
... OK

再次没有 x-permission

> chmod -x cmake/Modules/
> rm -rf _builds/
> cmake -H. -B_builds
...
CMake Error at CMakeLists.txt:5 (find_package):
  By not providing "FindMy.cmake" in CMAKE_MODULE_PATH this project has asked
  CMake to find a package configuration file provided by "My", but CMake did
  not find one.

关于macos - cmake find_package 在 Mac OS X 上不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24097327/

相关文章:

bash - VS代码: 'code' function is preventing me from launching code from shell

macos - 将 SwiftUI 应用程序中的顶部栏菜单项映射到打开特定的捆绑 PDF?

c++ - 如何使用 CMake 创建包

c++ - 链接到 Caffe 库的正确方法

c - 从大型 C 库创建一个子集

c++ - 在 C++ 中使用 GSL 蒙特卡罗积分求解多维函数

python - 如何在最新的 OS X 上安装多个版本的 Python 并并行使用它们?

regex - 如何在 unix (osx) 中搜索/替换一堆文本文件

android - 如何使用 CMake 依赖于 Android native 代码?

c++ - 如何使用 gsl 在 cholesky 中打印下矩阵?