mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Some checks failed
Bazel presubmit checks / bazel-build-check (macos-latest) (push) Has been cancelled
Bazel presubmit checks / bazel-build-check (ubuntu-latest) (push) Has been cancelled
Bazel presubmit checks / other-bazel-checks (push) Has been cancelled
CMake / build (push) Has been cancelled
Build on macOS / build (push) Has been cancelled
Multi GCC / build (push) Has been cancelled
Build on Windows / build (push) Has been cancelled
The master SDK branch (and the SDK release tags eg 2.1.1) should point to specific picotool tags, to ensure you get a compatible picotool (note this is beyond the 2.1.1 tag in master, so will just fix this for users who check out the HEAD of master)
81 lines
3.3 KiB
CMake
81 lines
3.3 KiB
CMake
# Finds (or builds) the picotool executable
|
|
#
|
|
# This will define the following imported targets
|
|
#
|
|
# picotool
|
|
#
|
|
cmake_minimum_required(VERSION 3.17)
|
|
|
|
if (NOT TARGET picotool)
|
|
include(ExternalProject)
|
|
|
|
if (DEFINED ENV{PICOTOOL_FETCH_FROM_GIT_PATH} AND (NOT PICOTOOL_FETCH_FROM_GIT_PATH))
|
|
set(PICOTOOL_FETCH_FROM_GIT_PATH $ENV{PICOTOOL_FETCH_FROM_GIT_PATH})
|
|
message("Using PICOTOOL_FETCH_FROM_GIT_PATH from environment ('${PICOTOOL_FETCH_FROM_GIT_PATH}')")
|
|
endif ()
|
|
|
|
include(FetchContent)
|
|
if (PICOTOOL_FETCH_FROM_GIT_PATH)
|
|
get_filename_component(picotool_INSTALL_DIR "${PICOTOOL_FETCH_FROM_GIT_PATH}" ABSOLUTE)
|
|
else ()
|
|
get_filename_component(picotool_INSTALL_DIR "${FETCHCONTENT_BASE_DIR}" ABSOLUTE)
|
|
endif ()
|
|
set(picotool_INSTALL_DIR ${picotool_INSTALL_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
|
|
|
|
set(picotool_BUILD_TARGET picotoolBuild)
|
|
set(picotool_TARGET picotool)
|
|
|
|
if (NOT TARGET ${picotool_BUILD_TARGET})
|
|
if (NOT PICOTOOL_FETCH_FROM_GIT_PATH)
|
|
message(WARNING
|
|
"No installed picotool with version ${picotool_VERSION_REQUIRED} found - building from source\n"
|
|
"It is recommended to build and install picotool separately, or to set PICOTOOL_FETCH_FROM_GIT_PATH "
|
|
"to a common directory for all your SDK projects"
|
|
)
|
|
endif()
|
|
|
|
message("Downloading Picotool")
|
|
FetchContent_Populate(picotool QUIET
|
|
GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
|
|
GIT_TAG 2.1.1
|
|
|
|
SOURCE_DIR ${picotool_INSTALL_DIR}/picotool-src
|
|
BINARY_DIR ${picotool_INSTALL_DIR}/picotool-build
|
|
SUBBUILD_DIR ${picotool_INSTALL_DIR}/picotool-subbuild
|
|
)
|
|
|
|
add_custom_target(picotoolForceReconfigure
|
|
${CMAKE_COMMAND} -E touch_nocreate "${CMAKE_SOURCE_DIR}/CMakeLists.txt"
|
|
VERBATIM)
|
|
|
|
ExternalProject_Add(${picotool_BUILD_TARGET}
|
|
PREFIX picotool
|
|
SOURCE_DIR ${picotool_SOURCE_DIR}
|
|
BINARY_DIR ${picotool_BINARY_DIR}
|
|
INSTALL_DIR ${picotool_INSTALL_DIR}
|
|
DEPENDS picotoolForceReconfigure
|
|
CMAKE_ARGS
|
|
"--no-warn-unused-cli"
|
|
"-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}"
|
|
"-DPICO_SDK_PATH:FILEPATH=${PICO_SDK_PATH}"
|
|
"-DPICOTOOL_NO_LIBUSB=1"
|
|
"-DPICOTOOL_FLAT_INSTALL=1"
|
|
"-DCMAKE_INSTALL_PREFIX=${picotool_INSTALL_DIR}"
|
|
"-DCMAKE_RULE_MESSAGES=OFF" # quieten the build
|
|
"-DCMAKE_INSTALL_MESSAGE=NEVER" # quieten the install
|
|
BUILD_ALWAYS 1 # force dependency checking
|
|
EXCLUDE_FROM_ALL TRUE
|
|
TEST_COMMAND
|
|
${picotool_INSTALL_DIR}/picotool/picotool
|
|
version ${picotool_VERSION_REQUIRED}
|
|
TEST_AFTER_INSTALL TRUE
|
|
)
|
|
endif()
|
|
|
|
set(picotool_EXECUTABLE ${picotool_INSTALL_DIR}/picotool/picotool)
|
|
add_executable(${picotool_TARGET} IMPORTED GLOBAL)
|
|
set_property(TARGET ${picotool_TARGET} PROPERTY IMPORTED_LOCATION
|
|
${picotool_EXECUTABLE})
|
|
|
|
add_dependencies(${picotool_TARGET} ${picotool_BUILD_TARGET})
|
|
endif()
|