summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/FetchContent.cmake22
-rw-r--r--Modules/FetchContent/CMakeLists.cmake.in2
-rw-r--r--Tests/RunCMake/FetchContent/DownloadFile.cmake9
-rw-r--r--Tests/RunCMake/FetchContent/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FetchContent/dummyFile.txt1
5 files changed, 35 insertions, 0 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 0e98f49..400754c 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -796,6 +796,8 @@ function(__FetchContent_directPopulate contentName)
SUBBUILD_DIR
SOURCE_DIR
BINARY_DIR
+ # We need special processing if DOWNLOAD_NO_EXTRACT is true
+ DOWNLOAD_NO_EXTRACT
# Prevent the following from being passed through
CONFIGURE_COMMAND
BUILD_COMMAND
@@ -846,6 +848,26 @@ function(__FetchContent_directPopulate contentName)
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
endforeach()
+ if(ARG_DOWNLOAD_NO_EXTRACT)
+ set(ARG_EXTRA "${ARG_EXTRA} DOWNLOAD_NO_EXTRACT YES")
+ set(__FETCHCONTENT_COPY_FILE
+"
+ExternalProject_Get_Property(${contentName}-populate DOWNLOADED_FILE)
+get_filename_component(dlFileName \"\${DOWNLOADED_FILE}\" NAME)
+
+ExternalProject_Add_Step(${contentName}-populate copyfile
+ COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
+ \"<DOWNLOADED_FILE>\" \"${ARG_SOURCE_DIR}\"
+ DEPENDEES patch
+ DEPENDERS configure
+ BYPRODUCTS \"${ARG_SOURCE_DIR}/\${dlFileName}\"
+ COMMENT \"Copying file to SOURCE_DIR\"
+)
+")
+ else()
+ unset(__FETCHCONTENT_COPY_FILE)
+ endif()
+
# Hide output if requested, but save it to a variable in case there's an
# error so we can show the output upon failure. When not quiet, don't
# capture the output to a variable because the user may want to see the
diff --git a/Modules/FetchContent/CMakeLists.cmake.in b/Modules/FetchContent/CMakeLists.cmake.in
index 0095b11..45e4df0 100644
--- a/Modules/FetchContent/CMakeLists.cmake.in
+++ b/Modules/FetchContent/CMakeLists.cmake.in
@@ -21,3 +21,5 @@ ExternalProject_Add(${contentName}-populate
USES_TERMINAL_DOWNLOAD YES
USES_TERMINAL_UPDATE YES
)
+
+@__FETCHCONTENT_COPY_FILE@
diff --git a/Tests/RunCMake/FetchContent/DownloadFile.cmake b/Tests/RunCMake/FetchContent/DownloadFile.cmake
new file mode 100644
index 0000000..741b6d3
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DownloadFile.cmake
@@ -0,0 +1,9 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ t1
+ URL ${CMAKE_CURRENT_LIST_DIR}/dummyFile.txt
+ DOWNLOAD_NO_EXTRACT YES
+)
+
+FetchContent_Populate(t1)
diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
index e28ae96..5e2e5e1 100644
--- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
@@ -6,6 +6,7 @@ run_cmake(MissingDetails)
run_cmake(DirectIgnoresDetails)
run_cmake(FirstDetailsWin)
run_cmake(DownloadTwice)
+run_cmake(DownloadFile)
run_cmake(SameGenerator)
run_cmake(VarDefinitions)
run_cmake(GetProperties)
diff --git a/Tests/RunCMake/FetchContent/dummyFile.txt b/Tests/RunCMake/FetchContent/dummyFile.txt
new file mode 100644
index 0000000..0a12ce1
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/dummyFile.txt
@@ -0,0 +1 @@
+# This file is used to verify fetching a single file directly