diff --git a/CMakeLists.txt b/CMakeLists.txt index 9249ec4..067b457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,23 @@ project ("openGLES 2.0 for Raspberry Pi tutorials") SET(COMPILE_DEFINITIONS -Werror) + if (CROSS_COMPILE) + message("Cross compilation mode enabled.") + + # Some cmake systems has bug, and uses install rpath + # always, even while building + # (CMAKE_BUILD_RPATH is always equal to CMAKE_INSTALL_RPATH). + # In cross-compilation case such rpath would be wrong. + # E.g. we don't need rpath=/opt/vc/lib + # but we need rpath=${ROOTFS}/opt/vc/lib + # Currently the we just hardcode that linker flag. + SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,${CMAKE_SOURCE_DIR}/libs/ilclient:${CMAKE_SYSROOT}/opt/vc/lib") +endif(CROSS_COMPILE) + include_directories( - /opt/vc/include - /opt/vc/include/interface/vcos/pthreads - /opt/vc/include/interface/vmcs_host/linux + ${CMAKE_SYSROOT}/opt/vc/include + ${CMAKE_SYSROOT}/opt/vc/include/interface/vcos/pthreads + ${CMAKE_SYSROOT}/opt/vc/include/interface/vmcs_host/linux # ${CMAKE_SOURCE_DIR}/libs/glm/ ${CMAKE_SOURCE_DIR}/libs/ilclient ${CMAKE_SOURCE_DIR}/common @@ -15,7 +28,7 @@ include_directories( link_directories( ${CMAKE_SOURCE_DIR}/libs/ilclient - /opt/vc/lib + ${CMAKE_SYSROOT}/opt/vc/lib ) diff --git a/encode_OGL/CMakeLists.txt b/encode_OGL/CMakeLists.txt index a685287..c8bc6ba 100644 --- a/encode_OGL/CMakeLists.txt +++ b/encode_OGL/CMakeLists.txt @@ -12,5 +12,7 @@ target_link_libraries(encode_OGL ${GL_LIBS} ${CAM_LIBS} ${ILC_LIBS} + m + pthread ) -set (CMAKE_C_FLAGS "-DOMX_SKIP64BIT -lpthread -lm") +set (CMAKE_C_FLAGS "-DOMX_SKIP64BIT") diff --git a/raspberry-toolchain.cmake b/raspberry-toolchain.cmake new file mode 100644 index 0000000..5a2546c --- /dev/null +++ b/raspberry-toolchain.cmake @@ -0,0 +1,36 @@ +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_VERSION 1) + +# Setup rootfs directory here +SET(PIROOT /home/stepan/projects/alpha_racing/raspberry-rootfs/rootfs) + +# Directory to raspberry cross compiling tools +SET(PITOOLS /opt/tools) + +SET(TOOLROOT ${PITOOLS}/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64) + +# specify the cross compiler +SET(CMAKE_C_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-gcc) +SET(CMAKE_CXX_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-g++) + +SET(CMAKE_SYSROOT ${PIROOT}) +SET(CMAKE_FIND_ROOT_PATH ${PIROOT}) + + +# search for programs in the build host directories +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + +# Some cmake systems has bug, and uses install rpath +# always, even while building. +# In cross-compilation case such rpath would be wrong. +# E.g. we don't need rpath=/opt/vc/lib +# but we need rpath=${ROOTFS}/opt/vc/lib +# Currently we should hardcode that linker flag in project CMakeLists.txt +SET(CMAKE_SKIP_BUILD_RPATH True) + +set(CROSS_COMPILE True) +