Skip to content

Commit

Permalink
switch to cmake for protobuf and allow shared target to consume it
Browse files Browse the repository at this point in the history
  • Loading branch information
csxwin committed Aug 21, 2023
1 parent 1bd0a99 commit 968e50d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 12 deletions.
24 changes: 19 additions & 5 deletions tools/install-deps-cross-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ install_deps() {
cd protobuf-${VERSION_PROTOBUF}
if [ ! -f ${NATIVE_PREFIX}/bin/protoc ]; then
mkdir build_native && cd build_native
../configure --prefix=${NATIVE_PREFIX}
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_INSTALL_PREFIX=${NATIVE_PREFIX} \
..
make install -j`nproc`
cd ..
fi
Expand All @@ -135,10 +141,18 @@ install_deps() {
LD=${TOOLCHAIN}/bin/ld \
RANLIB=${TOOLCHAIN}/bin/llvm-ranlib \
STRIP=${TOOLCHAIN}/bin/llvm-strip \
../configure \
--host=${HOST_PLATFORM} \
--prefix=${INSTALL_PREFIX} \
"CFLAGS=-fPIC" "CXXFLAGS=-fPIC"
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DANDROID_ABI=${TARGET_ARCH} \
-DANDROID_PLATFORM=android-${VERSION_ANDROID_API} \
-DCMAKE_ANDROID_NDK=${SDK_PREFIX}/ndk/${VERSION_ANDROID_NDK} \
-DCMAKE_TOOLCHAIN_FILE=${SDK_PREFIX}/ndk/${VERSION_ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_TOOLCHAIN=clang \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
..
make install -j`nproc`
cd ../..

Expand Down
18 changes: 15 additions & 3 deletions tools/install-deps-cross-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,24 @@ if ! ${USE_CACHE} || [ ! -d /usr/local/aarch64-linux-gnu ] || [ ! -d ${NATIVE_PR
tar -zxf protobuf-cpp-${VERSION_PROTOBUF}.tar.gz
cd protobuf-${VERSION_PROTOBUF}
mkdir build && cd build
../configure --prefix=${NATIVE_PREFIX}
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_INSTALL_PREFIX=${NATIVE_PREFIX} \
..
make install -j`nproc`
cd ..
mkdir build_arm64 && cd build_arm64
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ \
../configure --host=aarch64-linux --prefix=/usr/local/aarch64-linux-gnu
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/aarch64-linux-gnu/lib/cmake/arm64-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/aarch64-linux-gnu \
..
make install -j`nproc`
cd ../..

Expand Down
18 changes: 15 additions & 3 deletions tools/install-deps-cross-armhf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,24 @@ if ! ${USE_CACHE} || [ ! -d /usr/local/arm-linux-gnueabihf ] || [ ! -d ${NATIVE_
tar -zxf protobuf-cpp-${VERSION_PROTOBUF}.tar.gz
cd protobuf-${VERSION_PROTOBUF}
mkdir build && cd build
../configure --prefix=${NATIVE_PREFIX}
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_INSTALL_PREFIX=${NATIVE_PREFIX} \
..
make install -j`nproc`
cd ..
mkdir build_armhf && cd build_armhf
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
../configure --host=arm-linux --prefix=/usr/local/arm-linux-gnueabihf
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_TOOLCHAIN_FILE=/usr/local/arm-linux-gnueabihf/lib/cmake/armhf-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/arm-linux-gnueabihf \
..
make install -j`nproc`
cd ../..

Expand Down
8 changes: 7 additions & 1 deletion tools/install-deps-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ if ${INSTALL_BUILD_TIME_DEPS} && ( ! ${USE_CACHE} || [ ! -d ${PREFIX} ] ); then
tar -zxf protobuf-cpp-${VERSION_PROTOBUF}.tar.gz
cd protobuf-${VERSION_PROTOBUF}
mkdir build && cd build
../configure --prefix=${PREFIX}
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-Dprotobuf_BUILD_TESTS=Off \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
..
make install -j`nproc`
cd ../..

Expand Down

0 comments on commit 968e50d

Please sign in to comment.