#RPI2/RPI3 armv7 toolchain set(RPI True) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR armv7) set(SCOL_INSTALL_PREFIX "RPI2") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # cross-compiler set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) set(CMAKE_LINKER arm-linux-gnueabihf-ld) set(CMAKE_OBJCOPY arm-linux-gnueabihf-objcopy) set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf) list(APPEND CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf/lib /usr/arm-linux-gnueabihf/usr/lib /usr/lib/arm-linux-gnueabihf /opt/vc/lib/) set(CMAKE_INCLUDE_PATH /usr/include/arm-linux-gnueabihf) # Tell pkg-config to look for libraries set(ENV{PKG_CONFIG_PATH} "/usr/lib/arm-linux-gnueabihf/pkgconfig") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) # Todo add -mfpu=neon-vfpv4 #RPI 1 flags -mfpu=vfp -mfloat-abi=hard -march=armv6 -mtune=arm1176jzf-s #RPI 2 flags -march=armv7-a -mfpu=neon-vfpv4 -mtune=cortex-a7 #RPI 3 flags -march=armv8-a -mfpu=crypto-neon-fp-armv8 -mtune=cortex-a53 set(CMAKE_C_FLAGS "-fPIC -pipe -marm -mthumb-interwork -march=armv7-a -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux -mfloat-abi=hard -funsafe-math-optimizations -fomit-frame-pointer -fsigned-char" CACHE STRING "Flags for Raspberry Pi 2") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Flags for Raspberry Pi 2") set(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG" CACHE STRING "c++ Release flags" ) set(CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG" CACHE STRING "c Release flags" ) set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" ) set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" ) set(CMAKE_SKIP_RPATH 1) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags,-R,\\\$ORIGIN" CACHE STRING "Flags executables") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags,-R,\\\$ORIGIN" CACHE STRING "Flags shared") set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES}) add_definitions(-DRPI -DRPI2 -D__ARM_PCS_VFP -fPIC) # Find Python 3 interpreter find_package(Python3 COMPONENTS Interpreter) if(NOT Python3_FOUND) find_program(PYTHON_EXECUTABLE python3) if(NOT PYTHON_EXECUTABLE) message(FATAL_ERROR "Python3 not found. Please install Python3.") else() set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE PATH "Python executable" FORCE) endif() else() set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE PATH "Python executable" FORCE) endif()