如何在 OS X 上使用 CMake,针对新的 Arm M1

问题描述

我有一些使用 cmake 的依赖项,我需要编译,但我不确定我是否正确执行此操作。我目前正在我的 CFLAGS 中为 amd64 使用 -march=x86-64,这似乎有效,但我不确定这是否正确,因为当我尝试定位新的 M1 时它不起作用。我还应该做些什么来从命令行使用 cmake 来针对不同的架构?

export CFLAGS="-O2 -march=aarch64 -fomit-frame-pointer -fno-stack-protector -pipe"

cmake -B ${{github.workspace}}/build \
    -G "Unix Makefiles" \
    -D CMAKE_INSTALL_PREFIX=${{github.workspace}}/dist/darwin/arm64 \
    -D CMAKE_VERBOSE_MAKEFILE=ON \
    -D BUILD_SHARED_LIBS=ON \
    -D BUILD_DEMO=ON

cmake --build ${{github.workspace}}/build \
    --parallel 2 \
    --config RelWithDebInfo \
    --clean-first

cmake --install ${{github.workspace}}/build --config RelWithDebInfo

更新:我看到了这个错误。

CMake Error at /usr/local/Cellar/cmake/3.18.4/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

"/Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

-- Configuring incomplete,errors occurred!
See also "/Users/runner/work/project/project/build/CMakeFiles/CMakeOutput.log".

error: unknown target CPU 'aarch64'
note: valid target CPU values are: nocona,core2,penryn,bonnell,atom,silvermont,slm,goldmont,goldmont-plus,tremont,nehalem,corei7,westmere,sandybridge,corei7-avx,ivybridge,core-avx-i,haswell,core-avx2,broadwell,skylake,skylake-avx512,skx,cascadelake,cooperlake,cannonlake,icelake-client,icelake-server,tigerlake,knl,knm,k8,athlon64,athlon-fx,opteron,k8-sse3,athlon64-sse3,opteron-sse3,amdfam10,barcelona,btver1,btver2,bdver1,bdver2,bdver3,bdver4,znver1,znver2,x86-64
make[1]: *** [CMakeFiles/cmTC_72653.dir/testCCompiler.c.o] Error 1
make: *** [cmTC_72653/fast] Error 2

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...