Implement FetchPackage; a simple wrapper around FindOrFetch.
FetchPackage calls FindOrFetch, but sets USE_SYSTEM_PACKAGE to OFF (i.e. do not find, just fetch). It also sets EXCLUDE_FROM_ALL. PiperOrigin-RevId: 822565180 Change-Id: I70476f57b8d3371cefd02e840add279423913f3f
This commit is contained in:
committed by
Copybara-Service
parent
160b9480f9
commit
f217a8f987
+57
-5
@@ -11,7 +11,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
|
||||||
#.rst:
|
#.rst:
|
||||||
# FindOrFetch
|
# FindOrFetch
|
||||||
# ----------------------
|
# ----------------------
|
||||||
@@ -56,10 +56,7 @@
|
|||||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
||||||
# override this macro behaviour.
|
# override this macro behaviour.
|
||||||
|
|
||||||
if(COMMAND FindOrFetch)
|
if(NOT COMMAND FindOrFetch)
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
macro(FindOrFetch)
|
macro(FindOrFetch)
|
||||||
if(NOT FetchContent)
|
if(NOT FetchContent)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -138,3 +135,58 @@ macro(FindOrFetch)
|
|||||||
message(CHECK_PASS "found")
|
message(CHECK_PASS "found")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
#.rst:
|
||||||
|
# FetchPackage
|
||||||
|
# ----------------------
|
||||||
|
#
|
||||||
|
# Fetches a package from a Git repository in order to satisfy dependencies.
|
||||||
|
#
|
||||||
|
# FetchPackage([PACKAGE_NAME [name]]
|
||||||
|
# [GIT_REPO [repo]]
|
||||||
|
# [GIT_TAG [tag]]
|
||||||
|
# [PATCH_COMMAND [cmd] [args]]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# The command has the following parameters:
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - ``PACKAGE_NAME`` name of the package.
|
||||||
|
# - ``GIT_REPO`` git repository to fetch the library from.
|
||||||
|
# - ``GIT_TAG`` tag reference when fetching the library from the git repo.
|
||||||
|
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
|
||||||
|
# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
|
||||||
|
# for details on the parameter.
|
||||||
|
# - ``TARGETS`` (optional) list of targets to be satisfied. If any of these
|
||||||
|
# targets are not currently defined, this macro will attempt to fetch the
|
||||||
|
# package. If not specified, the package name will be used as the target.
|
||||||
|
#
|
||||||
|
# Note: This is a wrapper around FindOrFetch that sets EXCLUDE_FROM_ALL and
|
||||||
|
# USE_SYSTEM_PACKAGE to OFF.
|
||||||
|
if(NOT COMMAND FetchPackage)
|
||||||
|
function(FetchPackage)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
_ARGS
|
||||||
|
"EXCLUDE_FROM_ALL"
|
||||||
|
"PACKAGE_NAME;GIT_REPO;GIT_TAG"
|
||||||
|
"PATCH_COMMAND;TARGETS"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
if(NOT _ARGS_TARGETS)
|
||||||
|
set(_ARGS_TARGETS ${_ARGS_PACKAGE_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FindOrFetch(
|
||||||
|
PACKAGE_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
GIT_REPO ${_ARGS_GIT_REPO}
|
||||||
|
GIT_TAG ${_ARGS_GIT_TAG}
|
||||||
|
PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
|
||||||
|
TARGETS ${_ARGS_TARGETS}
|
||||||
|
USE_SYSTEM_PACKAGE OFF
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
|
||||||
#.rst:
|
#.rst:
|
||||||
# FindOrFetch
|
# FindOrFetch
|
||||||
# ----------------------
|
# ----------------------
|
||||||
@@ -56,10 +56,7 @@
|
|||||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
||||||
# override this macro behaviour.
|
# override this macro behaviour.
|
||||||
|
|
||||||
if(COMMAND FindOrFetch)
|
if(NOT COMMAND FindOrFetch)
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
macro(FindOrFetch)
|
macro(FindOrFetch)
|
||||||
if(NOT FetchContent)
|
if(NOT FetchContent)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -138,3 +135,58 @@ macro(FindOrFetch)
|
|||||||
message(CHECK_PASS "found")
|
message(CHECK_PASS "found")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
#.rst:
|
||||||
|
# FetchPackage
|
||||||
|
# ----------------------
|
||||||
|
#
|
||||||
|
# Fetches a package from a Git repository in order to satisfy dependencies.
|
||||||
|
#
|
||||||
|
# FetchPackage([PACKAGE_NAME [name]]
|
||||||
|
# [GIT_REPO [repo]]
|
||||||
|
# [GIT_TAG [tag]]
|
||||||
|
# [PATCH_COMMAND [cmd] [args]]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# The command has the following parameters:
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - ``PACKAGE_NAME`` name of the package.
|
||||||
|
# - ``GIT_REPO`` git repository to fetch the library from.
|
||||||
|
# - ``GIT_TAG`` tag reference when fetching the library from the git repo.
|
||||||
|
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
|
||||||
|
# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
|
||||||
|
# for details on the parameter.
|
||||||
|
# - ``TARGETS`` (optional) list of targets to be satisfied. If any of these
|
||||||
|
# targets are not currently defined, this macro will attempt to fetch the
|
||||||
|
# package. If not specified, the package name will be used as the target.
|
||||||
|
#
|
||||||
|
# Note: This is a wrapper around FindOrFetch that sets EXCLUDE_FROM_ALL and
|
||||||
|
# USE_SYSTEM_PACKAGE to OFF.
|
||||||
|
if(NOT COMMAND FetchPackage)
|
||||||
|
function(FetchPackage)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
_ARGS
|
||||||
|
"EXCLUDE_FROM_ALL"
|
||||||
|
"PACKAGE_NAME;GIT_REPO;GIT_TAG"
|
||||||
|
"PATCH_COMMAND;TARGETS"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
if(NOT _ARGS_TARGETS)
|
||||||
|
set(_ARGS_TARGETS ${_ARGS_PACKAGE_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FindOrFetch(
|
||||||
|
PACKAGE_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
GIT_REPO ${_ARGS_GIT_REPO}
|
||||||
|
GIT_TAG ${_ARGS_GIT_TAG}
|
||||||
|
PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
|
||||||
|
TARGETS ${_ARGS_TARGETS}
|
||||||
|
USE_SYSTEM_PACKAGE OFF
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
|
||||||
#.rst:
|
#.rst:
|
||||||
# FindOrFetch
|
# FindOrFetch
|
||||||
# ----------------------
|
# ----------------------
|
||||||
@@ -56,10 +56,7 @@
|
|||||||
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
# https://cmake.org/cmake/help/latest/module/FetchContent.html#variables to
|
||||||
# override this macro behaviour.
|
# override this macro behaviour.
|
||||||
|
|
||||||
if(COMMAND FindOrFetch)
|
if(NOT COMMAND FindOrFetch)
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
macro(FindOrFetch)
|
macro(FindOrFetch)
|
||||||
if(NOT FetchContent)
|
if(NOT FetchContent)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -138,3 +135,58 @@ macro(FindOrFetch)
|
|||||||
message(CHECK_PASS "found")
|
message(CHECK_PASS "found")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
#.rst:
|
||||||
|
# FetchPackage
|
||||||
|
# ----------------------
|
||||||
|
#
|
||||||
|
# Fetches a package from a Git repository in order to satisfy dependencies.
|
||||||
|
#
|
||||||
|
# FetchPackage([PACKAGE_NAME [name]]
|
||||||
|
# [GIT_REPO [repo]]
|
||||||
|
# [GIT_TAG [tag]]
|
||||||
|
# [PATCH_COMMAND [cmd] [args]]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# The command has the following parameters:
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - ``PACKAGE_NAME`` name of the package.
|
||||||
|
# - ``GIT_REPO`` git repository to fetch the library from.
|
||||||
|
# - ``GIT_TAG`` tag reference when fetching the library from the git repo.
|
||||||
|
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
|
||||||
|
# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
|
||||||
|
# for details on the parameter.
|
||||||
|
# - ``TARGETS`` (optional) list of targets to be satisfied. If any of these
|
||||||
|
# targets are not currently defined, this macro will attempt to fetch the
|
||||||
|
# package. If not specified, the package name will be used as the target.
|
||||||
|
#
|
||||||
|
# Note: This is a wrapper around FindOrFetch that sets EXCLUDE_FROM_ALL and
|
||||||
|
# USE_SYSTEM_PACKAGE to OFF.
|
||||||
|
if(NOT COMMAND FetchPackage)
|
||||||
|
function(FetchPackage)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
_ARGS
|
||||||
|
"EXCLUDE_FROM_ALL"
|
||||||
|
"PACKAGE_NAME;GIT_REPO;GIT_TAG"
|
||||||
|
"PATCH_COMMAND;TARGETS"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
if(NOT _ARGS_TARGETS)
|
||||||
|
set(_ARGS_TARGETS ${_ARGS_PACKAGE_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FindOrFetch(
|
||||||
|
PACKAGE_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
|
||||||
|
GIT_REPO ${_ARGS_GIT_REPO}
|
||||||
|
GIT_TAG ${_ARGS_GIT_TAG}
|
||||||
|
PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
|
||||||
|
TARGETS ${_ARGS_TARGETS}
|
||||||
|
USE_SYSTEM_PACKAGE OFF
|
||||||
|
EXCLUDE_FROM_ALL
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user