generated from Projetos/RaspberryPi_app
Initial commit
This commit is contained in:
71
rpi1-toolchain.cmake
Normal file
71
rpi1-toolchain.cmake
Normal file
@@ -0,0 +1,71 @@
|
||||
# rpi1-toolchain.cmake - Toolchain file for Raspberry Pi 1 (ARMv6)
|
||||
|
||||
# Additional settings for better compatibility
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
# Detect if we're in a try_compile invocation
|
||||
# During try_compile, BUILDROOT_PATH won't be available, but that's OK
|
||||
# because we set CMAKE_TRY_COMPILE_TARGET_TYPE above
|
||||
get_property(_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||
|
||||
if(NOT _IN_TRY_COMPILE)
|
||||
# Only validate during main configuration, not during try_compile
|
||||
if(NOT BUILDROOT_PATH)
|
||||
message(FATAL_ERROR
|
||||
"BUILDROOT_PATH is not defined!\n"
|
||||
"Please pass -DBUILDROOT_PATH=/path/to/buildroot when configuring CMake.\n"
|
||||
"Example: cmake -DBUILDROOT_PATH=/home/user/rpi1/buildroot ..."
|
||||
)
|
||||
endif()
|
||||
|
||||
# Verify BUILDROOT_PATH exists
|
||||
if(NOT EXISTS "${BUILDROOT_PATH}")
|
||||
message(FATAL_ERROR
|
||||
"BUILDROOT_PATH does not exist: ${BUILDROOT_PATH}\n"
|
||||
"Please check your .env file or cmake configuration."
|
||||
)
|
||||
endif()
|
||||
|
||||
# Cache it for use in this file during try_compile
|
||||
set(BUILDROOT_PATH "${BUILDROOT_PATH}" CACHE PATH "Path to buildroot directory" FORCE)
|
||||
endif()
|
||||
|
||||
# If BUILDROOT_PATH is not set (during try_compile), try to get it from cache
|
||||
if(NOT BUILDROOT_PATH)
|
||||
get_property(BUILDROOT_PATH CACHE BUILDROOT_PATH PROPERTY VALUE)
|
||||
endif()
|
||||
|
||||
# Specify the cross compiler
|
||||
set(TOOLCHAIN_PREFIX ${BUILDROOT_PATH}/output/host)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}/bin/arm-linux-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}/bin/arm-linux-g++)
|
||||
|
||||
# Specify the sysroot for finding libraries and headers
|
||||
set(CMAKE_SYSROOT ${TOOLCHAIN_PREFIX}/arm-buildroot-linux-gnueabihf/sysroot)
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
|
||||
# Only verify paths during main configuration
|
||||
if(NOT _IN_TRY_COMPILE)
|
||||
# Verify sysroot exists
|
||||
if(NOT EXISTS "${CMAKE_SYSROOT}")
|
||||
message(FATAL_ERROR
|
||||
"Sysroot not found: ${CMAKE_SYSROOT}\n"
|
||||
"Please check that buildroot is properly built."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Search for programs in the build host directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# Search for libraries and headers in the target directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# Specify target architecture flags
|
||||
set(CMAKE_C_FLAGS_INIT "-march=armv6 -mfpu=vfp -mfloat-abi=hard")
|
||||
set(CMAKE_CXX_FLAGS_INIT "-march=armv6 -mfpu=vfp -mfloat-abi=hard")
|
||||
Reference in New Issue
Block a user