Skip to content

Instantly share code, notes, and snippets.

@ast
Created December 25, 2018 12:17
Show Gist options
  • Save ast/b869d951c7f6d2963bab4f157e227de3 to your computer and use it in GitHub Desktop.
Save ast/b869d951c7f6d2963bab4f157e227de3 to your computer and use it in GitHub Desktop.
Builds GNURadio C++ OOT modules for Raspberry Pi 3
# Builds GNURadio C++ OOT modules for Raspberry Pi 3
# Created sysroot like this:
# rsync -rl --delete-after --safe-links pi@sdr.local:/{lib,usr} $HOME/src/sysroot
# used clang 7.0 and binutils 2.31
# mkdir build
# cd build
# cmake -DENABLE_DOXYGEN=OFF -DCMAKE_TOOLCHAIN_FILE=~/src/rbpi3.cmake ..
# If you have your pi mounted over sshfs you can do something like this:
# make -j8 install DESTDIR=/mnt/pi
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_SYSROOT $ENV{HOME}/src/sysroot)
SET(CMAKE_SDKROOT $ENV{HOME}/src/rbpisdk)
SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/src/sysroot)
SET(TRIPLE arm-linux-gnueabihf)
SET(PKG_CONFIG_EXECUTABLE ${TRIPLE}-pkg-config)
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
SET(RBPI3_FLAGS "-O3 -mcpu=cortex-a53 -march=armv7a -mfpu=neon-fp-armv8 -mfloat-abi=hard -funsafe-math-optimizations" CACHE STRING "" FORCE)
SET(COMPILER_PATH ${CMAKE_SYSROOT}/usr/lib/gcc/arm-linux-gnueabihf/6)
SET(GCC_TOOLS_PATH $ENV{HOME}/src/rbpisdk/arm-linux-gnueabihf)
# /usr/lib/arm-linux-gnueabihf/
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --target=arm-linux-gnueabihf ${RBPI3_FLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --target=arm-linux-gnueabihf ${RBPI3_FLAGS}" CACHE STRING "" FORCE)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -B{COMPILER_PATH} -L${COMPILER_PATH} -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf/ -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/arm-linux-gnueabihf" CACHE STRING "" FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -B{COMPILER_PATH} -L${COMPILER_PATH} -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf/ -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/arm-linux-gnueabihf" CACHE STRING "" FORCE)
SET(CMAKE_C_COMPILER ${CMAKE_SDKROOT}/bin/clang)
SET(CMAKE_CXX_COMPILER ${CMAKE_SDKROOT}/bin/clang++)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment