Toolchain-rpi.cmake 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. SET(CMAKE_SYSTEM_NAME Linux)
  2. SET(CMAKE_SYSTEM_VERSION 1)
  3. SET(CROSSROOT $ENV{HOME}/crosscompile)
  4. SET(DEVROOT ${CROSSROOT}/raspberrypi)
  5. SET(PIROOT ${DEVROOT}/rootfs)
  6. SET(PITOOLCHAIN ${DEVROOT}/tools)
  7. SET(TOOLROOT ${PITOOLCHAIN}/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf )
  8. SET(QT_BIN_PATH ${CROSSROOT}/Qt5/5.7/gcc_64/bin)
  9. # specify the cross compiler
  10. SET(CMAKE_C_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-gcc)
  11. SET(CMAKE_CXX_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-g++)
  12. SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf" )
  13. SET(CMAKE_SYSROOT ${PIROOT})
  14. SET(CMAKE_FIND_ROOT_PATH ${PIROOT})
  15. # search for programs in the build host directories
  16. SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  17. # for libraries and headers in the target directories
  18. SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  19. SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  20. #SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGES ONLY)
  21. #SET Flags for linking as dynamic linker config file is not being properly parsed by the toolchain
  22. # see https://solderspot.wordpress.com/2016/02/04/cross-compiling-for-raspberry-pi-part-ii/
  23. SET(FLAGS "-Wl,-rpath-link,${PIROOT}/opt/vc/lib -Wl,-rpath-link,${PIROOT}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/local/lib")
  24. UNSET(CMAKE_C_FLAGS CACHE)
  25. UNSET(CMAKE_CXX_FLAGS CACHE)
  26. SET(CMAKE_CXX_FLAGS ${FLAGS} CACHE STRING "" FORCE)
  27. SET(CMAKE_C_FLAGS ${FLAGS} CACHE STRING "" FORCE)
  28. link_directories(${PIROOT}/lib/arm-linux-gnueabihf)