Closed aplavin closed 9 months ago
You must use differrent build folders for these CMake invocations. Otherwise, the direction is correct.
Indeed, that seems to be the case, now it does attempt to cross compile. Still, cannot make it to succeed.
As an example, let's consider x64 linux as the host, and arm macos as the target. If I run the second cmake
as-is, it errors with
[ 0%] Linking CXX executable generate_mime_types_gperf
cd /workspace/srcdir/td/build/tdutils/generate && /usr/bin/cmake -E cmake_link_script CMakeFiles/generate_mime_types_gperf.dir/link.txt --verbose=1
ccache /opt/bin/aarch64-apple-darwin20-libgfortran5-cxx11/c++ -std=c++14 -fno-omit-frame-pointer -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wall -Wextra -Wpointer-arith -Wcast-qual -Wsign-compare -Wno-tautological-compare -Wpointer-arith -Wvla -Wnon-virtual-dtor -Wno-unused-parameter -Wconversion -Wno-sign-conversion -Wc++14-compat-pedantic -Wdeprecated -Wno-unused-command-line-argument -Qunused-arguments -Wno-unknown-warning-option -Wodr -O3 -DNDEBUG -Wl,--gc-sections -Wl,--exclude-libs,ALL CMakeFiles/generate_mime_types_gperf.dir/generate_mime_types_gperf.cpp.o -o generate_mime_types_gperf
ld64.lld: error: unknown argument '--gc-sections'
ld64.lld: error: unknown argument '--exclude-libs'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
and if I pass -DAPPLE=1
, then the error is different
[ 0%] Generating ../../../tdutils/generate/auto/mime_type_to_extension.gperf, ../../../tdutils/generate/auto/extension_to_mime_type.gperf
cd /workspace/srcdir/td/tdutils/generate && /workspace/srcdir/td/build/tdutils/generate/generate_mime_types_gperf mime_types.txt /workspace/srcdir/td/tdutils/generate/auto/mime_type_to_extension.gperf /workspace/srcdir/td/tdutils/generate/auto/extension_to_mime_type.gperf
/workspace/srcdir/td/build/tdutils/generate/generate_mime_types_gperf: line 1: syntax error: unexpected "("
Any ideas of what goes wrong?
CMake needs much more variables to be specified to be able correctly build the project for the target architecture. It is better to create a toolchain file that provides all needed variables. See https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html for examples of how to correctly cross-compile with CMake.
I'm trying to compile tdlib different platforms on the same host machine, but probably doing something wrong here. The end result always is the
so
library for the host machine...What I do:
What should be the correct sequence of steps?