Skip to content

Commit 9b512c3

Browse files
committed
Remove deprecated uses of FetchContent_Populate
Cannot use MakeAvailable as the files shouldn't be added to the build, so instead uses the full signature for FetchContent_Populate Fixes #2124
1 parent 969f589 commit 9b512c3

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

external/pico_sdk_import.cmake

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,26 @@ if (NOT PICO_SDK_PATH)
4040
if (PICO_SDK_FETCH_FROM_GIT_PATH)
4141
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
4242
endif ()
43-
# GIT_SUBMODULES_RECURSE was added in 3.17
44-
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
45-
FetchContent_Declare(
43+
FetchContent_Declare(
44+
pico_sdk
45+
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
46+
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
47+
)
48+
49+
if (NOT pico_sdk)
50+
message("Downloading Raspberry Pi Pico SDK")
51+
FetchContent_Populate(
4652
pico_sdk
53+
QUIET
4754
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
4855
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
4956
GIT_SUBMODULES_RECURSE FALSE
57+
58+
SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-src
59+
BINARY_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-build
60+
SUBBUILD_DIR ${FETCHCONTENT_BASE_DIR}/pico_sdk-subbuild
5061
)
51-
else ()
52-
FetchContent_Declare(
53-
pico_sdk
54-
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
55-
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
56-
)
57-
endif ()
5862

59-
if (NOT pico_sdk)
60-
message("Downloading Raspberry Pi Pico SDK")
61-
FetchContent_Populate(pico_sdk)
6263
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
6364
endif ()
6465
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})

tools/Findpicotool.cmake

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ if (NOT TARGET picotool)
1515
endif ()
1616

1717
include(FetchContent)
18-
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
1918
if (PICOTOOL_FETCH_FROM_GIT_PATH)
20-
get_filename_component(FETCHCONTENT_BASE_DIR "${PICOTOOL_FETCH_FROM_GIT_PATH}" ABSOLUTE)
19+
get_filename_component(picotool_INSTALL_DIR "${PICOTOOL_FETCH_FROM_GIT_PATH}" ABSOLUTE)
20+
else ()
21+
get_filename_component(picotool_INSTALL_DIR "${FETCHCONTENT_BASE_DIR}" ABSOLUTE)
2122
endif ()
23+
set(picotool_INSTALL_DIR ${picotool_INSTALL_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
2224

2325
set(picotool_BUILD_TARGET picotoolBuild)
2426
set(picotool_TARGET picotool)
@@ -32,20 +34,15 @@ if (NOT TARGET picotool)
3234
)
3335
endif()
3436

35-
FetchContent_Declare(
36-
picotool
37-
GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
38-
GIT_TAG develop
39-
GIT_PROGRESS true
40-
)
37+
message("Downloading Picotool")
38+
FetchContent_Populate(picotool QUIET
39+
GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
40+
GIT_TAG develop
4141

42-
FetchContent_GetProperties(picotool)
43-
set(picotool_INSTALL_DIR ${FETCHCONTENT_BASE_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
44-
if (NOT picotool_POPULATED)
45-
message("Downloading Picotool")
46-
FetchContent_Populate(picotool)
47-
endif ()
48-
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
42+
SOURCE_DIR ${picotool_INSTALL_DIR}/picotool-src
43+
BINARY_DIR ${picotool_INSTALL_DIR}/picotool-build
44+
SUBBUILD_DIR ${picotool_INSTALL_DIR}/picotool-subbuild
45+
)
4946

5047
add_custom_target(picotoolForceReconfigure
5148
${CMAKE_COMMAND} -E touch_nocreate "${CMAKE_SOURCE_DIR}/CMakeLists.txt"

0 commit comments

Comments
 (0)