我有一些依赖项需要使用cmake进行编译,但我不确定是否正确。我目前在CFLAGS中使用-march=x86-64
for amd64,这似乎可以正常工作,但我不确定是否正确,因为当我尝试以新的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
2条答案
按热度按时间xhv8bpkk1#
这就像添加CFLAG
-target arm64-apple-macos10.5
一样简单。e0bqpujr2#
使用
CMAKE_OSX_ARCHITECTURES
变量,正如我详细介绍的in this answer,将其设置为arm64
就足够了。