FetchContent
This commit is contained in:
parent
6e9fa0db82
commit
1c1d997f96
@ -199,6 +199,8 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
SUBBUILD_DIR
|
SUBBUILD_DIR
|
||||||
SOURCE_DIR
|
SOURCE_DIR
|
||||||
BINARY_DIR
|
BINARY_DIR
|
||||||
|
# We need special processing if DOWNLOAD_NO_EXTRACT is true
|
||||||
|
DOWNLOAD_NO_EXTRACT
|
||||||
# Prevent the following from being passed through
|
# Prevent the following from being passed through
|
||||||
CONFIGURE_COMMAND
|
CONFIGURE_COMMAND
|
||||||
BUILD_COMMAND
|
BUILD_COMMAND
|
||||||
@ -249,6 +251,26 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
||||||
endforeach()
|
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
|
# 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
|
# 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
|
# capture the output to a variable because the user may want to see the
|
||||||
@ -266,16 +288,16 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR)
|
if(CMAKE_GENERATOR)
|
||||||
set(generatorOpts "-G${CMAKE_GENERATOR}")
|
set(subCMakeOpts "-G${CMAKE_GENERATOR}")
|
||||||
if(CMAKE_GENERATOR_PLATFORM)
|
if(CMAKE_GENERATOR_PLATFORM)
|
||||||
list(APPEND generatorOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
list(APPEND subCMakeOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR_TOOLSET)
|
if(CMAKE_GENERATOR_TOOLSET)
|
||||||
list(APPEND generatorOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
list(APPEND subCMakeOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_MAKE_PROGRAM)
|
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()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
@ -283,7 +305,7 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
||||||
# trusted even if provided). We will have to rely on being
|
# trusted even if provided). We will have to rely on being
|
||||||
# able to find the default generator and build tool.
|
# able to find the default generator and build tool.
|
||||||
unset(generatorOpts)
|
unset(subCMakeOpts)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create and build a separate CMake project to carry out the population.
|
# 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"
|
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
|
||||||
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} ${generatorOpts} .
|
COMMAND ${CMAKE_COMMAND} ${subCMakeOpts} .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
${outputOptions}
|
${outputOptions}
|
||||||
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user