CMake target_include_directories(SYSTEM ...):SYSTEM选项似乎不工作在最近版本的CMake定位Xcode [英] CMake target_include_directories(SYSTEM ...): SYSTEM option does not seem to work on recent versions of CMake targeting Xcode

查看:3424
本文介绍了CMake target_include_directories(SYSTEM ...):SYSTEM选项似乎不工作在最近版本的CMake定位Xcode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个取决于Boost的应用程序,并且编译会在Boost头(tag_of.hpp)中生成大量警告类成员无法重新声明

We are building an application depending on Boost, and compilation generates a lot of warning "Class member cannot be redeclared" in a Boost header (tag_of.hpp).

为了避免构建日志的垃圾邮件,我们决定将Boost标题包含为系统标题:

To avoid spamming the build log, we decided to include Boost headers as system headers:

target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})

我们的理解是, include目录后面的 -isystem 编译器标志。

Our understanding is that this command should put Boost include directory behind a -isystemcompiler flags. Yet it does no such thing, instead putting it alongside 'normal' include directories in the header search path.

环境是 CMake 3.0.0 ,为 Xcode 5.1.1 生成项目文件。
这似乎是一些其他人的问题(请参阅此答案中的最后两个注释)。

The environment is CMake 3.0.0, generating a project file for Xcode 5.1.1. This seems to be an issue with some others (see last two comments in this answer).

是否有一个有效的方法来包含标题作为系统?

Is there a working way to include headers as system ?

EDIT :刚刚在相同的环境中测试,将CMake更新为版本 3.3.0 ,行为是一样的。

EDIT: Just tested in the same environment, updating CMake to version 3.3.0, and the behaviour is the same.

EDIT :这是一个显示我的环境问题的最小示例

EDIT: Here is a minimal example that is showing the issue on my environment

cmake_minimum_required(VERSION 3.0)

find_package(Boost 1.49 COMPONENTS)

project(system_dependencies)

add_executable(${PROJECT_NAME} main.cpp)

target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})

从此脚本生成的Xcode项目文件将生成设置中的Boost路径放置:标题搜索路径,而不是将其附加到 -isystem 编译器标志。这由IDE发出的编译命令确认:

The Xcode project file generated from this script places the path to Boost in the build setting: Header search path, instead of appending it behind a -isystem compiler flag. Which is confirmed by the compilation command issued by the IDE:


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain / usr / bin / clang
-x c ++ -arch x86_64 -fmessage-length = 0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit = 0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline -eof -Wno-c ++ 11-extensions -DCMAKE_INTDIR = \Debug \-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
-fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min = 10.9 -g -Wno-sign-conversion -I / Users /.../ system_dependencies / build / Debug / include

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.9 -g -Wno-sign-conversion -I/Users/.../system_dependencies/build/Debug/include

-I / Users /.../ SDK / boost / include

......


推荐答案

这个问题看起来只会发生在XCode生成器,因为CMake认为它不支持isystem标志。我认为最好的解决方案是报告这个问题在CMake bug tracker。

This issue looks to only occur for the XCode generator, as CMake believes it doesn't support the isystem flag. I would think the best solution is to report this issue on CMake bug tracker.

这篇关于CMake target_include_directories(SYSTEM ...):SYSTEM选项似乎不工作在最近版本的CMake定位Xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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