【发布时间】:2021-12-30 05:07:17
【问题描述】:
我正在尝试使用 Conan 和 GCC arm none eabi 和 Ninja Generator 来设置嵌入式 CMake 项目。
我已经设法设置了 Windows (Ninja) 和 Linux (WSL2) 版本。 现在我开始构建嵌入式目标。
从一个 cmake 预设 USE_SPDLOG 设置为“1.8.5”,
现在我的柯南工作流程符合https://github.com/conan-io/cmake-conan 中的建议
include(${CMAKE_BINARY_DIR}/conan.cmake)
if(USE_SPDLOG)
set(SPDLOG_PACKAGE "spdlog/${USE_SPDLOG}")
set(SPDLOG_ADDITIONAL_OPTIONS "spdlog:header_only=True")
endif()
conan_cmake_configure(
REQUIRES
${SPDLOG_PACKAGE}
OPTIONS
${SPDLOG_ADDITIONAL_OPTIONS}
GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(
PATH_OR_REFERENCE
.
BUILD
missing
REMOTE
conan-center
SETTINGS
${OS_SETTING}
${OS_VERSION_SETTING}
${ARCH_SETTING}
${settings})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
if(USE_SPDLOG)
conan_find_package(spdlog)
endif()
现在 Cmake 可以正确检测到我的交叉编译器(GCC 10.2,arm none eabi)
[CMake] -- The C compiler identification is GNU 10.2.1
1> [CMake] -- The CXX compiler identification is GNU 10.2.1
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/xxxx/toolchains/arm-none-eabi-gcc-10.2.1/bin/arm-none-eabi-gcc.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/xxxx/toolchains/arm-none-eabi-gcc-10.2.1/bin/arm-none-eabi-g++.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- The ASM compiler identification is GNU
1> [CMake] -- Found assembler: C:/xxxx/toolchains/arm-none-eabi-gcc-10.2.1/bin/arm-none-eabi-gcc.exe
所以在我的项目 gcc + ninja seam 中工作。
不过柯南开头是
[CMake] -- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
1> [CMake] -- Conan: checking conan executable
1> [CMake] -- Conan: Found program C:/Users/xxx/AppData/Local/Programs/Python/Python39/Scripts/conan.exe
1> [CMake] -- Conan: Version found Conan version 1.42.1
1> [CMake] -- Conan executing: C:/Users/xxxx/AppData/Local/Programs/Python/Python39/Scripts/conan.exe install . --remote conan-center --build missing --settings build_type=Debug --settings compiler=gcc --settings compiler.version=10 --settings compiler.libcxx=libstdc++11
1> [CMake] Configuration:
1> [CMake] [settings]
1> [CMake] arch=x86_64
1> [CMake] arch_build=x86_64
1> [CMake] build_type=Debug
1> [CMake] compiler=gcc
1> [CMake] compiler.libcxx=libstdc++11
1> [CMake] compiler.version=10
1> [CMake] os=Windows
1> [CMake] os_build=Windows
1> [CMake] [options]
1> [CMake] [build_requires]
1> [CMake] [env]
1> [CMake]
=>我相信柯南实际上并没有交叉编译
来自柯南文档 https://docs.conan.io/en/1.6/systems_cross_building/cross_building.html
我尝试添加
os_build=none
arch_build=arm
os=Windows
arch=x86_64
compiler=Visual Studio
到选项
但这会导致
ERROR: Invalid setting 'none
1> [CMake] arch_build=arm
1> [CMake] os=Windows
1> [CMake] arch=x86_64
1> [CMake] compiler=Visual Studio' is not a valid 'settings.os_build' value.
那么如何让嵌入式交叉编译工作?你有什么想法吗?
【问题讨论】:
-
根据文档,您似乎把事情搞混了:
arch_build用于构建系统,即系统,arch用于主机系统(出于某种原因,这里似乎是类似于目标系统;不熟悉柯南,所以没有一些研究我无法区分)。因此,由于您正在为 Linux arm 进行编译,它可能应该是arch_build=x86_64os_build=Windowsos=Linux和arch=arm在链接站点中的 Windows 到 Raspberry 及以下部分应列出示例;您可能想要/需要指定一个 arm 版本(ARM 架构参考)...