Skip to content

Commit 7454e45

Browse files
authored
Merge pull request hathach#2125 from hathach/cmake-detect-family
auto detect FAMILY based on BOARD
2 parents eb53680 + 200e58d commit 7454e45

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

.idea/cmake.xml

+23-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hw/bsp/family_support.cmake

+19-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@ if (NOT DEFINED TOOLCHAIN)
1111
set(TOOLCHAIN gcc)
1212
endif ()
1313

14-
if (NOT FAMILY)
15-
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")
14+
# FAMILY not defined, try to detect it from BOARD
15+
if (NOT DEFINED FAMILY)
16+
if (NOT DEFINED BOARD)
17+
message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
18+
You can do this via -DFAMILY=xxx on the cmake command line")
19+
endif ()
20+
21+
# Find path contains BOARD
22+
file(GLOB BOARD_PATH LIST_DIRECTORIES true
23+
RELATIVE ${TOP}/hw/bsp
24+
${TOP}/hw/bsp/*/boards/${BOARD}
25+
)
26+
if (NOT BOARD_PATH)
27+
message(FATAL_ERROR "Could not detect FAMILY from BOARD=${BOARD}")
28+
endif ()
29+
30+
# replace / with ; so that we can get the first element as FAMILY
31+
string(REPLACE "/" ";" BOARD_PATH ${BOARD_PATH})
32+
list(GET BOARD_PATH 0 FAMILY)
1633
endif ()
1734

1835
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)

0 commit comments

Comments
 (0)