Permalink
Browse files

added: convenience methods for compilation on the raspberry pi with n…

…on-standard system directories and cross compilation
  • Loading branch information...
opdenkamp committed Jul 3, 2015
1 parent 3b749cb commit bb7c8500c282d2bbb11b89c7decf8270dd95fb9d
Showing with 36 additions and 4 deletions.
  1. +14 −1 README.md
  2. +15 −0 cmake/CrossCompile.cmake
  3. +6 −2 src/libcec/cmake/CheckPlatformSupport.cmake
  4. +1 −1 src/libcec/cmake/LinkPlatformSupport.cmake
View
@@ -34,9 +34,22 @@ make
sudo make install
```
## Raspberry Pi ##
If you're compiling for a Raspberry Pi, then the path to the required headers and libraries can be set manually, in case it's not in a standard system directory:
```
cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..
cmake -DRPI_INCLUDE_DIR=/path/to/vc/include \
-DRPI_LIB_DIR=/path/to/vc/lib \
..
```
If you're cross compiling, then you can set the correct toolchain like this (for the Raspberry Pi):
```
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/CrossCompile.cmake \
-DXCOMPILE_BASE_PATH=/path/to/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi \
-DXCOMPILE_LIB_PATH=/path/to/firmware/hardfp/opt/vc/lib \
-DRPI_INCLUDE_DIR=/path/to/firmware/hardfp/opt/vc/include \
-DRPI_LIB_DIR=/path/to/firmware/hardfp/opt/vc/lib \
..
```
## Apple OS X
View
@@ -0,0 +1,15 @@
SET(XCOMPILE_BASE_PATH "" CACHE STRING "Path to the compiler")
SET(XCOMPILE_PREFIX "arm-bcm2708hardfp-linux-gnueabi-" CACHE STRING "Toolchain prefix")
SET(XCOMPILE_LIB_PATH "" CACHE STRING "Path to the libraries")
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER ${XCOMPILE_BASE_PATH}/bin/${XCOMPILE_PREFIX}gcc)
SET(CMAKE_CXX_COMPILER ${XCOMPILE_BASE_PATH}/bin/${XCOMPILE_PREFIX}g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH ${XCOMPILE_LIB_PATH})
@@ -13,6 +13,9 @@
# HAVE_P8_USB_DETECT 1 if Pulse-Eight devices can be auto-detected
#
SET(RPI_LIB_DIR "" CACHE STRING "Path to Rapsberry Pi libraries")
SET(RPI_INCLUDE_DIR "" CACHE STRING "Path to Rapsberry Pi headers")
set(PLATFORM_LIBREQUIRES "")
# Raspberry Pi libs and headers are in a non-standard path on some distributions
@@ -82,10 +85,11 @@ else()
find_library(RPI_BCM_HOST bcm_host ${RPI_LIB_DIR})
check_library_exists(bcm_host bcm_host_init ${RPI_LIB_DIR} HAVE_RPI_API)
if (HAVE_RPI_API)
set(LIB_INFO "${LIB_INFO}, 'RPi'")
find_library(RPI_VCOS vcos ${RPI_LIB_DIR} REQUIRED)
find_library(RPI_VCHIQ_ARM vchiq_arm ${RPI_LIB_DIR} REQUIRED)
include_directories(${RPI_INCLUDE_DIR})
include_directories(${RPI_INCLUDE_DIR} ${RPI_INCLUDE_DIR}/interface/vcos/pthreads ${RPI_INCLUDE_DIR}/interface/vmcs_host/linux)
set(LIB_INFO "${LIB_INFO}, 'RPi'")
set(CEC_SOURCES_ADAPTER_RPI adapter/RPi/RPiCECAdapterDetection.cpp
adapter/RPi/RPiCECAdapterCommunication.cpp
adapter/RPi/RPiCECAdapterMessageQueue.cpp)
@@ -28,7 +28,7 @@ endif()
# raspberry pi
if (HAVE_RPI_API)
target_link_libraries(cec ${RPI_VCOS} ${RPI_VCHIQ_ARM} ${RPI_BCM_HOST})
target_link_libraries(cec ${RPI_VCOS} ${RPI_VCHIQ_ARM} ${RPI_BCM_HOST})
endif()
# Apple

0 comments on commit bb7c850

Please sign in to comment.