Allow compilation on operating systems different than ubuntu/debian

This commit is contained in:
Andrea Cavalli 2021-10-16 18:04:49 +02:00
parent bcb0deea2d
commit c0d05ac5ec
3 changed files with 25 additions and 17 deletions

View File

@ -106,7 +106,6 @@ cmake \
"-DTd_DIR=$(realpath -m ../td_bin/lib/cmake/Td/)" \ "-DTd_DIR=$(realpath -m ../td_bin/lib/cmake/Td/)" \
"-DJAVA_SRC_DIR=$(realpath -m ../src/main/jni-java-src/)" \ "-DJAVA_SRC_DIR=$(realpath -m ../src/main/jni-java-src/)" \
"-DTDNATIVES_CPP_SRC_DIR:PATH=$(realpath -m ../src/main/jni-cpp-src/)" \ "-DTDNATIVES_CPP_SRC_DIR:PATH=$(realpath -m ../src/main/jni-cpp-src/)" \
-DOPENSSL_USE_STATIC_LIBS=True \
${CMAKE_EXTRA_ARGUMENTS_TDJNI} \ ${CMAKE_EXTRA_ARGUMENTS_TDJNI} \
${CMAKE_EXTRA_ARGUMENTS} \ ${CMAKE_EXTRA_ARGUMENTS} \
"$(realpath -m ../src/main/jni-cpp-src/)" "$(realpath -m ../src/main/jni-cpp-src/)"

View File

@ -128,22 +128,22 @@ if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
cd "$ROOT_DIR" cd "$ROOT_DIR"
{ {
echo "set(CMAKE_SYSTEM_PROCESSOR ${CPU_ARCH_LINUX})"; echo "set(CMAKE_SYSTEM_PROCESSOR ${CPU_ARCH_LINUX})";
echo "set(CMAKE_C_COMPILER ${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-gcc)"; echo "set(CMAKE_C_COMPILER ${CROSS_CC})";
echo "set(CMAKE_C_COMPILER_TARGET ${CLANG_TRIPLE})"; echo "set(CMAKE_C_COMPILER_TARGET ${CLANG_TRIPLE})";
echo "set(CMAKE_CXX_COMPILER ${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-g++)"; echo "set(CMAKE_CXX_COMPILER ${CROSS_CXX})";
echo "set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TRIPLE})"; echo "set(CMAKE_CXX_COMPILER_TARGET ${CLANG_TRIPLE})";
echo "set(CMAKE_ASM_COMPILER ${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-g++)"; echo "set(CMAKE_ASM_COMPILER ${CROSS_CXX})";
echo "set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TRIPLE})"; echo "set(CMAKE_ASM_COMPILER_TARGET ${CLANG_TRIPLE})";
echo "set(CMAKE_LIBRARY_PATH \"$CROSS_BUILD_DEPS_DIR/\")"; echo "set(CMAKE_LIBRARY_PATH \"$CROSS_BUILD_DEPS_DIR/\")";
echo "include_directories(\"${CROSS_BUILD_DEPS_DIR}/usr/include/${CPU_ARCH_LINUX}-linux-${CPU_COMPILATION_TOOL}/\")"; echo "include_directories(\"${CROSS_BUILD_DEPS_DIR}/usr/include/${CPU_ARCH_LINUX}-linux-${CPU_COMPILATION_TOOL}/\")";
echo "SET(CMAKE_FIND_ROOT_PATH \"$CROSS_BUILD_DEPS_DIR\" \"$JAVA_HOME\" \"/\" \"/usr/lib/jvm/java-11-openjdk-amd64/include\")"; echo "SET(CMAKE_FIND_ROOT_PATH \"$CROSS_BUILD_DEPS_DIR\" \"$JAVA_HOME\" \"/\" \"$JAVA_HOME/include\")";
echo "include_directories(\"${CROSS_OPENJDK_PATH}/include\")"; echo "include_directories(\"${CROSS_OPENJDK_PATH}/include\")";
echo "include_directories(\"${CROSS_OPENJDK_PATH}/include/linux\")"; echo "include_directories(\"${CROSS_OPENJDK_PATH}/include/linux\")";
echo "SET(JAVA_HOME \"/usr/lib/jvm/java-11-openjdk-amd64/\")"; echo "SET(JAVA_HOME \"$JAVA_HOME/\")";
echo "SET(JAVA_INCLUDE_PATH \"/usr/lib/jvm/java-11-openjdk-amd64/include\")"; echo "SET(JAVA_INCLUDE_PATH \"$JAVA_HOME/include\")";
echo "SET(JAVA_AWT_INCLUDE_PATH \"/usr/lib/jvm/java-11-openjdk-amd64/include\")"; echo "SET(JAVA_AWT_INCLUDE_PATH \"$JAVA_HOME/include\")";
echo "SET(JAVA_INCLUDE_PATH2 \"/usr/lib/jvm/java-11-openjdk-amd64/include/linux\")"; echo "SET(JAVA_INCLUDE_PATH2 \"$JAVA_HOME/include/linux\")";
#echo "SET(JAVA_JVM_LIBRARY \"/usr/lib/jvm/java-11-openjdk-amd64/jre/lib/amd64/${JAVA_INSTALLATION_TYPE}/libjvm.so\")"; #echo "SET(JAVA_JVM_LIBRARY \"/usr/lib/jvm/java-11-openjdk-amd64/jre/lib/amd64/${JAVA_INSTALLATION_TYPE}/libjvm.so\")";
#echo "SET(JAVA_AWT_LIBRARY \"/usr/lib/jvm/java-11-openjdk-amd64/jre/lib/amd64/libawt.so\")"; #echo "SET(JAVA_AWT_LIBRARY \"/usr/lib/jvm/java-11-openjdk-amd64/jre/lib/amd64/libawt.so\")";

View File

@ -71,12 +71,16 @@ if [[ "$CORE_VARIABLES_SET" != "YES" ]]; then
export CPU_CORES_NUM="2" export CPU_CORES_NUM="2"
unset CROSS_BUILD_DEPS_DIR unset CROSS_BUILD_DEPS_DIR
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then if [[ "$OPERATING_SYSTEM_NAME" == "windows" ]]; then
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then export CMAKE_EXTRA_ARGUMENTS_TDJNI="${CMAKE_EXTRA_ARGUMENTS_TDJNI} -DOPENSSL_USE_STATIC_LIBS=True"
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS" elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
else export CMAKE_EXTRA_ARGUMENTS_TDJNI="${CMAKE_EXTRA_ARGUMENTS_TDJNI} -DOPENSSL_USE_STATIC_LIBS=True"
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS -DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\"" elif [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
fi #if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
#export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS"
#else
#export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS -DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\""
#fi
if [[ "$CPU_ARCHITECTURE_NAME" == "386" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armhf" ]]; then if [[ "$CPU_ARCHITECTURE_NAME" == "386" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armhf" ]]; then
export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic" export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic"
@ -89,8 +93,13 @@ if [[ "$CORE_VARIABLES_SET" != "YES" ]]; then
export CXX="g++" export CXX="g++"
export CROSS_CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++" export CROSS_CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
if [[ "${CPU_ARCH_CMAKE}" == "x86_64" && "${CPU_COMPILATION_TOOL}" == "gnu" ]]; then
export CROSS_CC="gcc"
export CROSS_CXX="g++"
else
export CROSS_CC="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-gcc" export CROSS_CC="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-gcc"
export CROSS_CXX="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-g++" export CROSS_CXX="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-g++"
fi
CROSS_BUILD_DEPS_DIR="$(realpath "../../")/.cache/tdlib-build-cross-${CPU_ARCH_DPKG}/" CROSS_BUILD_DEPS_DIR="$(realpath "../../")/.cache/tdlib-build-cross-${CPU_ARCH_DPKG}/"
export CROSS_BUILD_DEPS_DIR export CROSS_BUILD_DEPS_DIR