使用cmake时如何将VS2017指向(arm-none-eabi-)gcc默认标头

问题描述 投票:1回答:2

我正在尝试用arm-none-eabi-gcc构建一个项目/测试cmake作为我的编译器使用VS2017(以及VS2019RC /预览版)。

我很难告诉VS2017在哪里寻找默认的gcc头文件。

实现这一目标的正确/最简单的方法是什么?

gcc cmake visual-studio-2017 visual-studio-2019
2个回答
0
投票

我知道我可以像普通包含一样包含它们但是试图寻找配置选项,并在下面找到如何将其推送到INCLUDE env变量的链接。

https://devblogs.microsoft.com/cppblog/arm-gcc-cross-compilation-in-visual-studio/

您可以指定其他包含目录,但请注意,此时还必须显式声明子目录(如果存在)。

[code lang=”js”]
{
// The "environments" property is an array of key value pairs of the form
// { "EnvVar1": "Value1", "EnvVar2": "Value2" }
"environments": [
{
"INCLUDE": "${workspaceRoot}\\src\\includes"
}
],

{
  "configurations": [
    {
      "inheritEnvironments": [
        "gcc-arm"
      ],
      "name": "gccarm",
      "includePath": [
        "${env.INCLUDE}"
      ],
      "defines": [
      ]
    }
  ]
}

0
投票

所以我有一个解决方法,那就是有效。但这绝对不是一个长期的解决方案。

我所做的是直接在CMakeLists.txttarget_include_directories指令中添加GCC包含路径,这是有效的。像这样:

target_include_directories(
    ${ELF}
    PRIVATE
        "source"
        "source/target/arm/stm32f1/CMSIS/Device/ST/STM32F1xx/Include"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1/arm-none-eabi"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include/c++/7.3.1/backward"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/include"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/include-fixed"
        "${tools}\\bin\\../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/include"
)

但是,没有人想要这样的解决方案。所以,如果有人有更好的主意?

© www.soinside.com 2019 - 2024. All rights reserved.