简体   繁体   English

C++、CMake 和 Xcode 符号导航器

[英]C++, CMake, and Xcode Symbol Navigator

I am creating C++ project that uses CMake to generate a XCode project.我正在创建使用 CMake 生成 XCode 项目的 C++ 项目。 It uses the Boost FileSystem with the lines of code它使用带有代码行的 Boost FileSystem

  SET(BOOST_ROOT ~/libs/boost/boost_1_64_0)
  set(Boost_USE_STATIC_LIBS   ON)
  FIND_PACKAGE(Boost 1.64 EXACT REQUIRED COMPONENTS filesystem)
  include_directories(${Boost_INCLUDE_DIRS})

but now the Symbol Navigator is polluted with thousands of Boost classes但现在符号导航器被数千个 Boost 类污染了

符号导航器

Is there any way to exclude these?有什么办法可以排除这些吗? It's unclear what power I have since my project is generated in cmake.由于我的项目是在 cmake 中生成的,我不清楚我有什么权力。 I took a guess and say that my includes were originally #include "boost/filesystem.hpp" and changed that to #include <boost/filesystem.hpp> but that doesn't appear to make a difference.我猜测并说我的包含最初是#include "boost/filesystem.hpp"并将其更改为#include <boost/filesystem.hpp>但这似乎没有什么区别。 Next, I thought there might be a flag on the cmake include directory command so tried include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) but that didn't work.接下来,我认为 cmake include directory 命令上可能有一个标志,所以尝试了include_directories(SYSTEM ${Boost_INCLUDE_DIRS})但这没有用。

Is there a way to indicate that xcode should not include these directories in the navigator?有没有办法指示 xcode 不应在导航器中包含这些目录?

Use the filters at the bottom:使用底部的过滤器:

  • Show only classes and protocols: Click the Classes and Protocols button () in the filter bar at the bottom.仅显示类和协议:单击底部过滤器栏中的类和协议按钮 ()。
  • Show only project symbols: Click the Project Symbols button () in the filter bar at the bottom.仅显示项目符号:点按底部过滤器栏中的“项目符号”按钮 ()。

https://help.apple.com/xcode/mac/current/#/dev2241bf769 https://help.apple.com/xcode/mac/current/#/dev2241bf769


Instead of setting include_directories , try setting HEADER_SEARCH_PATHS for the target.不要设置include_directories ,而是尝试为目标设置HEADER_SEARCH_PATHS

You may need to edit the Boost_INCLUDE_DIRS to make it a space separated string of quoted filepaths.您可能需要编辑Boost_INCLUDE_DIRS以使其成为带引号的文件路径的空格分隔字符串。

set_target_properties(${target_name} PROPERTIES XCODE_ATTRIBUTE_USER_HEADER_SEARCH_PATHS "${Boost_INCLUDE_DIRS}")

https://help.apple.com/xcode/mac/current/#/itcaec37c2a6 https://help.apple.com/xcode/mac/current/#/itcaec37c2a6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CMake Xcode在问题导航器中使用错误的文件 - CMake Xcode using wrong files in Issue Navigator xcode c / c ++链接器错误:未定义符号 - xcode c/c++ linker error: undefined symbol 什么CMake变量用于在XCode中设置C ++标准库? - What CMake variable is used to set C++ Standard Library in XCode? Xcode 自动完成功能不适用于通过 CMake 包含的 C++ 库 - Xcode autocompletion does not work for C++ libraries included via CMake 如何在xcode 3中搜索C ++符号? - How can I search for a C++ symbol in xcode 3? 在 CMake 项目中从 C++ 调用 C 代码。 未定义的符号。 有外部 C - Calling C code from C++ in a CMake project. Undefined symbol. Have extern C Xcode-在Project Navigator中创建新的C ++文件-Order .h和.cpp-Order - Xcode - Create new C++ File - Order .h and .cpp - Order in Project Navigator Xcode Test Navigator 如何在纯 C++ 项目中显示 Google 测试 - How Xcode Test Navigator can show Google Tests in a pure C++ Project 在 OSx 上使用 CMake 构建 C++ 项目:ld:未找到架构 x86_64 的符号 - Building a C++ project with CMake on OSx: ld: symbol(s) not found for architecture x86_64 使用CMake链接错误以在C ++中创建共享库,因为符号的多个定义 - Linking error using CMake to create a shared library in C++ because multiple definition of symbol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM