c++ - CMAKE_OSX_DEPLOYMENT_TARGET 在 Yosemite 上自动设置为 '10.10'

标签 c++ macos cmake osx-yosemite vrpn

我正在尝试编译 VRPN我的 OS X 10.10.5 上的库。

我设置了 cmake configuration使用:ccmake ../vrpn。当我尝试配置项目时,出现以下错误:

CMake Error at /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/Platform/Darwin.cmake:76 (message):
   CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but CMAKE_OSX_SYSROOT:
    ""
   is not set to a MacOSX SDK with a recognized version.  Either set
   CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
   empty.
Call Stack (most recent call first):
   /usr/local/Cellar/cmake/3.4.0/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
   CMakeLists.txt:3 (project)

CMake Error: Internal CMake error, TryCompile configure of cmake failed

最终CMake错误,cmake的TryCompile配置失败

我在配置中看到变量:

CMAKE_OSX_DEPLOYMENT_TARGET      10.10

当再次尝试配置项目时,我收到以下消息以及之前的错误:

CMAKE_OSX_DEPLOYMENT_TARGET is '10.10' but the matching SDK does not exist
   at:
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk"

Instead using SDK:
 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk".

很明显,问题是默认的 cmake 配置设置了错误的 SDK 版本。

我将版本更改为 10.11 :

CMAKE_OSX_DEPLOYMENT_TARGET      10.11

然后我根据需要设置 CMAKE_OSX_SYSROOT:

CMAKE_OSX_SYSROOT    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

配置没问题,但我收到以下错误:

Could NOT find Threads (missing: Threads_FOUND)

令我惊讶的是,在另一个 CMakeLists.txt 上,我尝试获取 Threads 库并且 cmake 执行正常:

cmake_minimum_required (VERSION 3.4) 
find_package(Threads REQUIRED)

我认为问题是自定义 CMAKE_OSX_SYSROOTCMAKE_OSX_DEPLOYMENT_TARGET 导致找不到 Threads 包。但是每次我尝试从 ccmake 配置中删除 CMAKE_OSX_DEPLOYMENT_TARGETCMAKE_OSX_SYSROOT 时,我都会收到第一条错误消息和 CMAKE_OSX_DEPLOYMENT_TARGET 重置为 10.10

你有什么信息/测试可以帮助我解决这个问题吗?

最佳答案

将 Xcode 更新到 8.1 并安装命令行工具为我解决了这个问题

xcode-select --install

关于c++ - CMAKE_OSX_DEPLOYMENT_TARGET 在 Yosemite 上自动设置为 '10.10',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34312077/

相关文章:

c++ - 检查彼此相邻的两个下划线

c++ - 一个点绕另一个点旋转的函数

c++ - 调试 C/C++ 语言不命中断点

mysql - 无法连接到通过 Homebrew 安装的 MySQL @127.0.0.1

windows - 如果环境变量有空格,find_path 不起作用

linux - 来自外部 Parquet 项目静态库的 "undefined reference"错误

c++ - 我无法使用 cmake 链接静态库

c++ - 文本在窗口 Opengl 上不可见

c++ - 如何强制 Windows 向所有应用程序发送 'LOW_MEMORY' 信号?

excel - `Application.StatusBar` 是否在 Office 2011 中工作?