1# PICO_CMAKE_CONFIG: PICO_PLATFORM, platform to build for e.g. rp2040/host, default=rp2040 or environment value, group=build
2if (DEFINED ENV{PICO_PLATFORM} AND (NOT PICO_PLATFORM))
3    set(PICO_PLATFORM $ENV{PICO_PLATFORM})
4    message("Using PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
5else()
6    if (NOT PICO_PLATFORM)
7        set(PICO_PLATFORM "rp2040")
8        pico_message("Defaulting PICO_PLATFORM to ${PICO_PLATFORM} since not specified.")
9    else()
10        message("PICO platform is ${PICO_PLATFORM}.")
11    endif()
12endif ()
13
14set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, host)")
15
16# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, custom CMake file to use to set up the platform environment, default=none, group=build
17set(PICO_CMAKE_PRELOAD_PLATFORM_FILE "" CACHE INTERNAL "")
18set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms" CACHE INTERNAL "")
19
20if (NOT PICO_CMAKE_PRELOAD_PLATFORM_FILE)
21    set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
22endif ()
23
24if (NOT EXISTS "${PICO_CMAKE_PRELOAD_PLATFORM_FILE}")
25    message(FATAL_ERROR "${PICO_CMAKE_PRELOAD_PLATFORM_FILE} does not exist. \
26    Either specify a valid PICO_PLATFORM (or PICO_CMAKE_PRELOAD_PLATFORM_FILE).")
27endif ()
28
29include(${PICO_CMAKE_PRELOAD_PLATFORM_FILE})
30