fsfw-example-linux-mcu/cmake/PreProjectConfig.cmake

67 lines
1.9 KiB
CMake
Raw Normal View History

2021-06-11 12:51:20 +02:00
function(pre_project_config)
# Basic input sanitization
if(DEFINED TGT_BSP)
if(${TGT_BSP} MATCHES "arm/raspberrypi" AND NOT ${OS_FSFW} MATCHES linux)
message(STATUS "FSFW OSAL invalid for specified target BSP ${TGT_BSP}!")
message(STATUS "Setting valid OS_FSFW: linux")
set(OS_FSFW "linux")
endif()
endif()
2021-06-11 13:42:16 +02:00
if(${OS_FSFW} STREQUAL linux AND TGT_BSP)
2021-06-11 12:51:20 +02:00
if(${TGT_BSP} MATCHES "host/none")
elseif(${TGT_BSP} MATCHES "arm/raspberrypi")
2021-07-14 16:35:19 +02:00
if(NOT DEFINED ENV{LINUX_ROOTFS})
2021-06-11 12:51:20 +02:00
if(NOT RASPBIAN_ROOTFS)
2021-07-14 16:35:19 +02:00
message(FATAL_ERROR "LINUX_ROOTFS must be set to Raspberry Pi rootfs location")
2021-06-11 12:51:20 +02:00
else()
2021-07-14 16:35:19 +02:00
set(ENV{LINUX_ROOTFS} "${LINUX_ROOTFS}")
2021-06-11 12:51:20 +02:00
endif()
else()
message(STATUS
2021-07-14 16:35:19 +02:00
"LINUX_ROOTFS from environmental variables used: "
"$ENV{LINUX_ROOTFS}"
2021-06-11 12:51:20 +02:00
)
endif()
if(NOT DEFINED ENV{RASPBERRY_VERSION})
if(NOT RASPBERRY_VERSION)
message(STATUS "No RASPBERRY_VERSION specified, setting to 4")
set(RASPBERRY_VERSION "4" CACHE STRING "Raspberry Pi version")
else()
message(STATUS
"Setting RASPBERRY_VERSION to ${RASPBERRY_VERSION}"
)
set(RASPBERRY_VERSION
${RASPBERRY_VERSION} CACHE STRING "Raspberry Pi version"
)
set(ENV{RASPBERRY_VERSION} ${RASPBERRY_VERSION})
endif()
else()
message(STATUS
"RASPBERRY_VERSION from environmental variables used: "
"$ENV{RASPBERRY_VERSION}"
)
endif()
2021-06-11 13:42:16 +02:00
2021-06-11 12:51:20 +02:00
if(LINUX_CROSS_COMPILE)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SCRIPT_PATH}/RPiCrossCompileConfig.cmake"
PARENT_SCOPE
)
endif()
elseif(${TGT_BSP} MATCHES "arm/beagleboneblack")
if(LINUX_CROSS_COMPILE)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SCRIPT_PATH}/BBBCrossCompileConfig.cmake"
PARENT_SCOPE
)
endif()
else()
message(WARNING "Target BSP (TGT_BSP) ${TGT_BSP} unknown!")
endif()
endif()
endfunction()