2022-03-17 14:28:32 +01:00
|
|
|
if(DEFINED ENV{ZYNQ_7020_SYSROOT})
|
|
|
|
set(ENV{ZYNQ_7020_ROOTFS} $ENV{ZYNQ_7020_SYSROOT})
|
2021-08-23 15:08:48 +02:00
|
|
|
endif()
|
2020-12-29 01:40:47 +01:00
|
|
|
# CROSS_COMPILE also needs to be set accordingly or passed to the CMake command
|
2022-03-17 14:28:32 +01:00
|
|
|
if(NOT DEFINED ENV{ZYNQ_7020_ROOTFS})
|
2021-07-15 01:21:42 +02:00
|
|
|
# Sysroot has not been cached yet and was not set in environment either
|
|
|
|
if(NOT DEFINED SYSROOT_PATH)
|
|
|
|
message(FATAL_ERROR
|
2022-03-17 14:28:32 +01:00
|
|
|
"Define the ZYNQ_7020_ROOTFS variable to point to the Zynq-7020 rootfs."
|
2021-07-15 01:21:42 +02:00
|
|
|
)
|
|
|
|
endif()
|
2020-12-29 22:20:38 +01:00
|
|
|
else()
|
2022-03-17 14:28:32 +01:00
|
|
|
set(SYSROOT_PATH "$ENV{ZYNQ_7020_ROOTFS}" CACHE PATH "Zynq-7020 root filesystem path")
|
2020-12-29 22:20:38 +01:00
|
|
|
endif()
|
2020-12-29 01:40:47 +01:00
|
|
|
|
|
|
|
if(NOT DEFINED ENV{CROSS_COMPILE})
|
2022-08-18 19:04:49 +02:00
|
|
|
set(CROSS_COMPILE "")
|
2020-12-29 01:40:47 +01:00
|
|
|
message(STATUS
|
|
|
|
"No CROSS_COMPILE environmental variable set, using default ARM linux "
|
|
|
|
"cross compiler name ${CROSS_COMPILE}"
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(CROSS_COMPILE "$ENV{CROSS_COMPILE}")
|
|
|
|
message(STATUS
|
|
|
|
"Using environmental variable CROSS_COMPILE as cross-compiler: "
|
|
|
|
"$ENV{CROSS_COMPILE}"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-02-01 11:17:20 +01:00
|
|
|
message(STATUS "Using sysroot path: ${SYSROOT_PATH}")
|
2020-12-29 01:40:47 +01:00
|
|
|
|
2022-08-18 19:04:49 +02:00
|
|
|
set(CROSS_COMPILE_CC "${CROSS_COMPILE}gcc")
|
|
|
|
set(CROSS_COMPILE_CXX "${CROSS_COMPILE}g++")
|
|
|
|
set(CROSS_COMPILE_LD "${CROSS_COMPILE}ld")
|
|
|
|
set(CROSS_COMPILE_AR "${CROSS_COMPILE}ar")
|
|
|
|
set(CROSS_COMPILE_RANLIB "${CROSS_COMPILE}ranlib")
|
|
|
|
set(CROSS_COMPILE_STRIP "${CROSS_COMPILE}strip")
|
|
|
|
set(CROSS_COMPILE_NM "${CROSS_COMPILE}nm")
|
|
|
|
set(CROSS_COMPILE_OBJCOPY "${CROSS_COMPILE}objcopy")
|
|
|
|
set(CROSS_COMPILE_SIZE "${CROSS_COMPILE}size")
|
2020-12-29 01:40:47 +01:00
|
|
|
|
|
|
|
# At the very least, cross compile gcc and g++ have to be set!
|
2021-07-15 01:21:42 +02:00
|
|
|
find_program (CMAKE_C_COMPILER ${CROSS_COMPILE_CC} REQUIRED)
|
|
|
|
find_program (CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX} REQUIRED)
|
|
|
|
# Useful utilities, not strictly necessary
|
|
|
|
find_program(CMAKE_SIZE ${CROSS_COMPILE_SIZE})
|
|
|
|
find_program(CMAKE_OBJCOPY ${CROSS_COMPILE_OBJCOPY})
|
2021-08-14 15:25:30 +02:00
|
|
|
find_program(CMAKE_STRIP ${CROSS_COMPILE_STRIP})
|
2020-12-29 01:40:47 +01:00
|
|
|
|
2022-08-18 19:04:49 +02:00
|
|
|
#set(CMAKE_CROSSCOMPILING TRUE)
|
|
|
|
#set(CMAKE_SYSROOT "${SYSROOT_PATH}")
|
2020-12-29 01:40:47 +01:00
|
|
|
|
|
|
|
# Define name of the target system
|
|
|
|
set(CMAKE_SYSTEM_NAME "Linux")
|
2022-08-18 19:04:49 +02:00
|
|
|
#set(CMAKE_SYSTEM_PROCESSOR "armv7")
|
2020-12-29 01:40:47 +01:00
|
|
|
|
|
|
|
# Define the compiler
|
|
|
|
set(CMAKE_C_COMPILER ${CROSS_COMPILE_CC})
|
|
|
|
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX})
|
|
|
|
|
2021-07-30 16:40:24 +02:00
|
|
|
if(EIVE_SYSROOT_MAGIC)
|
|
|
|
# List of library dirs where LD has to look. Pass them directly through gcc.
|
|
|
|
set(LIB_DIRS
|
|
|
|
"${SYSROOT_PATH}/usr/include"
|
|
|
|
"${SYSROOT_PATH}/usr/include/linux"
|
|
|
|
"${SYSROOT_PATH}/usr/lib"
|
|
|
|
"${SYSROOT_PATH}/lib"
|
|
|
|
"${SYSROOT_PATH}"
|
|
|
|
"${SYSROOT_PATH}/usr/lib/arm-xiphos-linux-gnueabi"
|
|
|
|
)
|
|
|
|
# You can additionally check the linker paths if you add the
|
|
|
|
# flags ' -Xlinker --verbose'
|
|
|
|
set(COMMON_FLAGS "-I${SYSROOT_PATH}/usr/lib")
|
|
|
|
foreach(LIB ${LIB_DIRS})
|
|
|
|
set(COMMON_FLAGS "${COMMON_FLAGS} -L${LIB} -Wl,-rpath-link,${LIB}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2020-12-29 01:40:47 +01:00
|
|
|
|
2022-08-18 19:04:49 +02:00
|
|
|
#set(CMAKE_PREFIX_PATH
|
|
|
|
# "${CMAKE_PREFIX_PATH}"
|
|
|
|
# # "${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}"
|
|
|
|
#)
|
2020-12-29 01:40:47 +01:00
|
|
|
|
2022-02-25 11:34:42 +01:00
|
|
|
set(C_FLAGS
|
2022-08-18 19:04:49 +02:00
|
|
|
# -mcpu=cortex-a9
|
|
|
|
# -mfpu=neon-vfpv3
|
|
|
|
# -mfloat-abi=hard
|
2022-02-25 11:34:42 +01:00
|
|
|
${COMMON_FLAGS}
|
|
|
|
-lgpiod
|
|
|
|
)
|
|
|
|
|
2022-03-18 06:45:40 +01:00
|
|
|
if (TGT_BSP MATCHES "arm/q7s")
|
2022-08-18 19:04:49 +02:00
|
|
|
# set(C_FLAGS ${C_FLAGS} -lxiphos)
|
2022-03-18 06:45:40 +01:00
|
|
|
endif()
|
|
|
|
|
2022-02-25 11:34:42 +01:00
|
|
|
string (REPLACE ";" " " C_FLAGS "${C_FLAGS}")
|
|
|
|
|
2020-12-29 01:40:47 +01:00
|
|
|
set(CMAKE_C_FLAGS
|
2022-02-25 11:34:42 +01:00
|
|
|
${C_FLAGS}
|
2022-03-17 14:28:32 +01:00
|
|
|
CACHE STRING "C flags for Zynq-7020"
|
2020-12-29 01:40:47 +01:00
|
|
|
)
|
|
|
|
set(CMAKE_CXX_FLAGS
|
2022-02-25 11:34:42 +01:00
|
|
|
"${CMAKE_C_FLAGS}"
|
2022-03-17 14:28:32 +01:00
|
|
|
CACHE STRING "CPP flags for Zynq-7020"
|
2020-12-29 01:40:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# search for programs in the build host directories
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
# 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)
|