Skip to content

Commit 4dd4c4d

Browse files
committed
Set FETCHCONTENT_SOURCE_DIR so that repos are only checked out once
The cmake scripts to fetch content such as llvm-project and picolibc can be called by both the top-level project as well as the sub-projects. To prevent the content being checked out and patched repeatedly, the FETCHCONTENT_SOURCE_DIR_<PROJECT> variables should be defined as these will override the declared source on any subsequent calls. These variables are already passed down from top-level to sub-project, however the variables themselves are never defined unless configured by a user. This patch addresses this by setting the variables inside the fetch scripts as soon as the fetch content is declared.
1 parent 92d729a commit 4dd4c4d

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

cmake/fetch_llvm.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ FetchContent_Declare(llvmproject
3131
SOURCE_SUBDIR do_not_add_llvm_subdir_yet
3232
)
3333
FetchContent_MakeAvailable(llvmproject)
34+
FetchContent_GetProperties(llvmproject SOURCE_DIR FETCHCONTENT_SOURCE_DIR_LLVMPROJECT)

cmake/fetch_newlib.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ FetchContent_Declare(newlib
2323
SOURCE_SUBDIR do_not_add_newlib_subdir
2424
)
2525
FetchContent_MakeAvailable(newlib)
26+
FetchContent_GetProperties(newlib SOURCE_DIR FETCHCONTENT_SOURCE_DIR_NEWLIB)

cmake/fetch_picolibc.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ FetchContent_Declare(picolibc
2929
SOURCE_SUBDIR do_not_add_picolibc_subdir
3030
)
3131
FetchContent_MakeAvailable(picolibc)
32+
FetchContent_GetProperties(picolibc SOURCE_DIR FETCHCONTENT_SOURCE_DIR_PICOLIBC)

0 commit comments

Comments
 (0)