FetchContent

This commit is contained in:
Andrei Astafev 2022-10-08 18:55:37 +03:00
parent 6e9fa0db82
commit 1c1d997f96

View File

@ -199,6 +199,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
@ -249,6 +251,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
@ -266,16 +288,16 @@ function(__FetchContent_directPopulate contentName)
endif()
if(CMAKE_GENERATOR)
set(generatorOpts "-G${CMAKE_GENERATOR}")
set(subCMakeOpts "-G${CMAKE_GENERATOR}")
if(CMAKE_GENERATOR_PLATFORM)
list(APPEND generatorOpts "-A${CMAKE_GENERATOR_PLATFORM}")
list(APPEND subCMakeOpts "-A${CMAKE_GENERATOR_PLATFORM}")
endif()
if(CMAKE_GENERATOR_TOOLSET)
list(APPEND generatorOpts "-T${CMAKE_GENERATOR_TOOLSET}")
list(APPEND subCMakeOpts "-T${CMAKE_GENERATOR_TOOLSET}")
endif()
if(CMAKE_MAKE_PROGRAM)
list(APPEND generatorOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
endif()
else()
@ -283,7 +305,7 @@ function(__FetchContent_directPopulate contentName)
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
# trusted even if provided). We will have to rely on being
# able to find the default generator and build tool.
unset(generatorOpts)
unset(subCMakeOpts)
endif()
# Create and build a separate CMake project to carry out the population.
@ -294,7 +316,7 @@ function(__FetchContent_directPopulate contentName)
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
execute_process(
COMMAND ${CMAKE_COMMAND} ${generatorOpts} .
COMMAND ${CMAKE_COMMAND} ${subCMakeOpts} .
RESULT_VARIABLE result
${outputOptions}
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"