diff options
| author | hathach <[email protected]> | 2023-06-26 13:38:24 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2023-06-26 13:38:24 +0700 |
| commit | 200e58d11ec6aceec31867129508c77f7989d051 (patch) | |
| tree | 6a889f572e605160c5a41c3e565ae93b44f2f1a6 /hw | |
| parent | eb53680a067d0ed3a57c457ee762a408b1afaaed (diff) | |
auto detect FAMILY based on BOARD
Diffstat (limited to 'hw')
| -rw-r--r-- | hw/bsp/family_support.cmake | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake index 73e674c18..93cab8723 100644 --- a/hw/bsp/family_support.cmake +++ b/hw/bsp/family_support.cmake @@ -11,8 +11,25 @@ if (NOT DEFINED TOOLCHAIN) set(TOOLCHAIN gcc) endif () -if (NOT FAMILY) - message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, eps32s2, esp32s3). You can do this via -DFAMILY=xxx on the cmake command line") +# FAMILY not defined, try to detect it from BOARD +if (NOT DEFINED FAMILY) + if (NOT DEFINED BOARD) + message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif). + You can do this via -DFAMILY=xxx on the cmake command line") + endif () + + # Find path contains BOARD + file(GLOB BOARD_PATH LIST_DIRECTORIES true + RELATIVE ${TOP}/hw/bsp + ${TOP}/hw/bsp/*/boards/${BOARD} + ) + if (NOT BOARD_PATH) + message(FATAL_ERROR "Could not detect FAMILY from BOARD=${BOARD}") + endif () + + # replace / with ; so that we can get the first element as FAMILY + string(REPLACE "/" ";" BOARD_PATH ${BOARD_PATH}) + list(GET BOARD_PATH 0 FAMILY) endif () if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake) |
