# RPI2/3 arm64 toolchain set(RPI True) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR aarch64) set(SCOL_INSTALL_PREFIX "RPI4") set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Cross-compiler set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) set(CMAKE_LINKER aarch64-linux-gnu-ld) set(CMAKE_OBJCOPY aarch64-linux-gnu-objcopy) set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) list(APPEND CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu/lib /usr/aarch64-linux-gnu/usr/lib /usr/lib/aarch64-linux-gnu /opt/vc/lib/) # Tell pkg-config to look for libraries set(ENV{PKG_CONFIG_PATH} "/usr/lib/aarch64-linux-gnu/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) # Corrected C and C++ flags set(CMAKE_C_FLAGS "-pipe -march=armv8-a -mtune=cortex-a53 -mabi=lp64 -funsafe-math-optimizations -fomit-frame-pointer -fsigned-char" CACHE STRING "Flags for Raspberry Pi 3/4") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Flags for Raspberry Pi 3/4") set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "C++ Release flags") set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "C Release flags") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "C++ Debug flags") set(CMAKE_C_FLAGS_DEBUG "-O0 -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 for executables") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags,-R,\\\$ORIGIN" CACHE STRING "Flags for shared libraries") set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_FIND_LIBRARY_SUFFIXES}) add_definitions(-DRPI -DRPI4 -fPIC)