Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated uses of FetchContent_Populate #2169

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions external/pico_sdk_import.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,26 @@ if (NOT PICO_SDK_PATH)
if (PICO_SDK_FETCH_FROM_GIT_PATH)
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
endif ()
# GIT_SUBMODULES_RECURSE was added in 3.17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the new version of the code still need to do something different if we're using an older version of CMake which doesn't support GIT_SUBMODULES_RECURSE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will fix that - although I was wondering if we should remove that anyway, as there are no longer any recursive submodules now that TinyUSB doesn't have any submodules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that TinyUSB doesn't have any submodules

Good point, I hadn't considered that! But might be better to err on the side of caution though, just in case we add any other submodules in future which do have submodules of their own? 🤔

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
FetchContent_Declare(
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
)

if (NOT pico_sdk)
message("Downloading Raspberry Pi Pico SDK")
FetchContent_Populate(
pico_sdk
QUIET
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
GIT_SUBMODULES_RECURSE FALSE

SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
)
else ()
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
)
endif ()

if (NOT pico_sdk)
message("Downloading Raspberry Pi Pico SDK")
FetchContent_Populate(pico_sdk)
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
endif ()
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
Expand Down
27 changes: 12 additions & 15 deletions tools/Findpicotool.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ if (NOT TARGET picotool)
endif ()

include(FetchContent)
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
if (PICOTOOL_FETCH_FROM_GIT_PATH)
get_filename_component(FETCHCONTENT_BASE_DIR "${PICOTOOL_FETCH_FROM_GIT_PATH}" ABSOLUTE)
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)
Expand All @@ -32,20 +34,15 @@ if (NOT TARGET picotool)
)
endif()

FetchContent_Declare(
picotool
GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
GIT_TAG develop
GIT_PROGRESS true
)
message("Downloading Picotool")
FetchContent_Populate(picotool QUIET
GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
GIT_TAG develop

FetchContent_GetProperties(picotool)
set(picotool_INSTALL_DIR ${FETCHCONTENT_BASE_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
if (NOT picotool_POPULATED)
message("Downloading Picotool")
FetchContent_Populate(picotool)
endif ()
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
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"
Expand Down
Loading