OS X 下的 CMake 警告:未为以下目标指定 MACOSX_RPATH [英] CMake warnings under OS X: MACOSX_RPATH is not specified for the following targets

查看:36
本文介绍了OS X 下的 CMake 警告:未为以下目标指定 MACOSX_RPATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 OS X (Yosemite) 下构建一个基于 CMake 的软件,它可以在 Fedora 21 下成功构建.它使用了一堆库.两者,像 Boost 这样的大开放文件和一些位于/installation_folder/lib 中的自写文件.我使用 CMake 版本 3.3.0.

I try to build a CMake-based software under OS X (Yosemite) which can be built successfully under Fedora 21. It uses a bunch of libraries. Both, big open ones like Boost and some self-written ones lying in /installation_folder/lib. I use CMake version 3.3.0.

执行后

mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=/usr/local/Cellar/gcc/5.2.0/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/local/Cellar/gcc/5.2.0/bin/g++-5  -DCMAKE_MODULE_PATH=${PWD}/../external/install/share/llvm/cmake 

我收到以下警告:

CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
--help-policy CMP0042" for policy details.  Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

ClangWrapper
Structure
WCETXML

This warning is for project developers.  Use -Wno-dev to suppress it.

CMakeLists.txt 包含以下有关 RPATH 的行:

The CMakeLists.txt contains the following lines regarding RPATH:

SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)

IF("${isSystemDir}" STREQUAL "-1")
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")

我只能说 ${CMAKE_INSTALL_PREFIX}/lib 确实是正确的路径,并且可以正确找到其他库,例如 Boost.

All I can say is that ${CMAKE_INSTALL_PREFIX}/lib is indeed the correct path, and that other libraries like Boost are found correctly.

忽略警告并在构建目录中继续使用make"会导致链接错误.

Ignoring the warnings and continuing with "make" in the build directory results in a linking error.

我阅读了CMake Wiki RPATH 处理文章,但我仍然无法区分这些路径变量及其在 OS X 上的正确使用.

I read the CMake Wiki RPATH handling article, but I am still not able to distinguish between these path variables and their correct use on OS X.

推荐答案

set(CMAKE_MACOSX_RPATH 1) 添加到 CMakeLists.txt 中,在上面写的语句之前,让警告消失.执行make后的链接问题依然存在.这让我假设我的 RPATH 设置与我的链接问题无关.

Adding set(CMAKE_MACOSX_RPATH 1) into CMakeLists.txt, before the above written statements, lets the warnings disappear. The linking problem after executing make stays. This brings me to the assumption that my RPATH setup has nothing to do with my linking problem.

尽管如此,这个线程的问题还是解决了.关于正确使用 CMakeLists.txt 中的 RPATH 选项的解释仍然非常受欢迎!

Nevertheless, this thread's problem is solved. An explanation about the correct use of the RPATH options inside CMakeLists.txt is still very welcome!

这篇关于OS X 下的 CMake 警告:未为以下目标指定 MACOSX_RPATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆