Use cmake FILE(COPY) for deploying custom CMakeLists.txt.

PiperOrigin-RevId: 838696575
Change-Id: I3c61bda9d1d89185f257797c2e0c0f4ef2c7cb95
This commit is contained in:
Haroon Qureshi
2025-12-01 03:36:36 -08:00
committed by Copybara-Service
parent fe74ea2e7b
commit c6b587b515
7 changed files with 49 additions and 19 deletions
+15 -1
View File
@@ -23,6 +23,7 @@
# [LIBRARY_NAME [name]] # [LIBRARY_NAME [name]]
# [GIT_REPO [repo]] # [GIT_REPO [repo]]
# [GIT_TAG [tag]] # [GIT_TAG [tag]]
# [CUSTOM_CMAKE [path]]
# [PATCH_COMMAND [cmd] [args]] # [PATCH_COMMAND [cmd] [args]]
# [TARGETS [targets]] # [TARGETS [targets]]
# [EXCLUDE_FROM_ALL]) # [EXCLUDE_FROM_ALL])
@@ -42,6 +43,9 @@
# ``USE_SYSTEM_PACKAGE`` is ``ON``. # ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``GIT_TAG`` tag reference when fetching the library from the git # - ``GIT_TAG`` tag reference when fetching the library from the git
# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``. # repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository. Ignored if
# ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -70,6 +74,7 @@ if(NOT COMMAND FindOrFetch)
LIBRARY_NAME LIBRARY_NAME
GIT_REPO GIT_REPO
GIT_TAG GIT_TAG
CUSTOM_CMAKE
) )
set(multi_value_args PATCH_COMMAND TARGETS) set(multi_value_args PATCH_COMMAND TARGETS)
cmake_parse_arguments( cmake_parse_arguments(
@@ -121,6 +126,12 @@ if(NOT COMMAND FindOrFetch)
FetchContent_GetProperties(${_ARGS_LIBRARY_NAME}) FetchContent_GetProperties(${_ARGS_LIBRARY_NAME})
if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED}) if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED})
FetchContent_Populate(${_ARGS_LIBRARY_NAME}) FetchContent_Populate(${_ARGS_LIBRARY_NAME})
if(NOT "${_ARGS_CUSTOM_CMAKE}" STREQUAL "")
file(COPY
"${_ARGS_CUSTOM_CMAKE}"
DESTINATION "${${_ARGS_LIBRARY_NAME}_SOURCE_DIR}"
)
endif()
add_subdirectory( add_subdirectory(
${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR} ${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR}
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
@@ -156,6 +167,8 @@ endif()
# - ``PACKAGE_NAME`` name of the package. # - ``PACKAGE_NAME`` name of the package.
# - ``GIT_REPO`` git repository to fetch the library from. # - ``GIT_REPO`` git repository to fetch the library from.
# - ``GIT_TAG`` tag reference when fetching the library from the git repo. # - ``GIT_TAG`` tag reference when fetching the library from the git repo.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -170,7 +183,7 @@ if(NOT COMMAND FetchPackage)
cmake_parse_arguments( cmake_parse_arguments(
_ARGS _ARGS
"EXCLUDE_FROM_ALL" "EXCLUDE_FROM_ALL"
"PACKAGE_NAME;GIT_REPO;GIT_TAG" "PACKAGE_NAME;GIT_REPO;GIT_TAG;CUSTOM_CMAKE"
"PATCH_COMMAND;TARGETS" "PATCH_COMMAND;TARGETS"
${ARGN} ${ARGN}
) )
@@ -183,6 +196,7 @@ if(NOT COMMAND FetchPackage)
LIBRARY_NAME ${_ARGS_PACKAGE_NAME} LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
GIT_REPO ${_ARGS_GIT_REPO} GIT_REPO ${_ARGS_GIT_REPO}
GIT_TAG ${_ARGS_GIT_TAG} GIT_TAG ${_ARGS_GIT_TAG}
CUSTOM_CMAKE ${_ARGS_CUSTOM_CMAKE}
PATCH_COMMAND ${_ARGS_PATCH_COMMAND} PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
TARGETS ${_ARGS_TARGETS} TARGETS ${_ARGS_TARGETS}
USE_SYSTEM_PACKAGE OFF USE_SYSTEM_PACKAGE OFF
+1 -4
View File
@@ -24,8 +24,5 @@ fetchpackage(
PACKAGE_NAME dear_imgui PACKAGE_NAME dear_imgui
GIT_REPO https://github.com/ocornut/imgui.git GIT_REPO https://github.com/ocornut/imgui.git
GIT_TAG ${MUJOCO_DEP_VERSION_dear_imgui} GIT_TAG ${MUJOCO_DEP_VERSION_dear_imgui}
PATCH_COMMAND CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/dear_imgui/CMakeLists.txt"
"cp"
"${CMAKE_SOURCE_DIR}/cmake/third_party_deps/dear_imgui/CMakeLists.txt"
"${FETCHCONTENT_BASE_DIR}/dear_imgui-src/CMakeLists.txt"
) )
+1 -4
View File
@@ -24,8 +24,5 @@ fetchpackage(
PACKAGE_NAME font_awesome PACKAGE_NAME font_awesome
GIT_REPO https://github.com/FortAwesome/Font-Awesome.git GIT_REPO https://github.com/FortAwesome/Font-Awesome.git
GIT_TAG ${MUJOCO_DEP_VERSION_font_awesome} GIT_TAG ${MUJOCO_DEP_VERSION_font_awesome}
PATCH_COMMAND CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/font_awesome/CMakeLists.txt"
"cp"
"${CMAKE_SOURCE_DIR}/cmake/third_party_deps/font_awesome/CMakeLists.txt"
"${FETCHCONTENT_BASE_DIR}/font_awesome-src/CMakeLists.txt"
) )
+1 -4
View File
@@ -24,8 +24,5 @@ fetchpackage(
PACKAGE_NAME implot PACKAGE_NAME implot
GIT_REPO https://github.com/epezent/implot.git GIT_REPO https://github.com/epezent/implot.git
GIT_TAG ${MUJOCO_DEP_VERSION_implot} GIT_TAG ${MUJOCO_DEP_VERSION_implot}
PATCH_COMMAND CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/implot/CMakeLists.txt"
"cp"
"${CMAKE_SOURCE_DIR}/cmake/third_party_deps/implot/CMakeLists.txt"
"${FETCHCONTENT_BASE_DIR}/implot-src/CMakeLists.txt"
) )
+1 -4
View File
@@ -24,8 +24,5 @@ fetchpackage(
PACKAGE_NAME opensans PACKAGE_NAME opensans
GIT_REPO https://github.com/googlefonts/opensans.git GIT_REPO https://github.com/googlefonts/opensans.git
GIT_TAG ${MUJOCO_DEP_VERSION_opensans} GIT_TAG ${MUJOCO_DEP_VERSION_opensans}
PATCH_COMMAND CUSTOM_CMAKE "${CMAKE_SOURCE_DIR}/cmake/third_party_deps/opensans/CMakeLists.txt"
"cp"
"${CMAKE_SOURCE_DIR}/cmake/third_party_deps/opensans/CMakeLists.txt"
"${FETCHCONTENT_BASE_DIR}/opensans-src/CMakeLists.txt"
) )
+15 -1
View File
@@ -23,6 +23,7 @@
# [LIBRARY_NAME [name]] # [LIBRARY_NAME [name]]
# [GIT_REPO [repo]] # [GIT_REPO [repo]]
# [GIT_TAG [tag]] # [GIT_TAG [tag]]
# [CUSTOM_CMAKE [path]]
# [PATCH_COMMAND [cmd] [args]] # [PATCH_COMMAND [cmd] [args]]
# [TARGETS [targets]] # [TARGETS [targets]]
# [EXCLUDE_FROM_ALL]) # [EXCLUDE_FROM_ALL])
@@ -42,6 +43,9 @@
# ``USE_SYSTEM_PACKAGE`` is ``ON``. # ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``GIT_TAG`` tag reference when fetching the library from the git # - ``GIT_TAG`` tag reference when fetching the library from the git
# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``. # repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository. Ignored if
# ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -70,6 +74,7 @@ if(NOT COMMAND FindOrFetch)
LIBRARY_NAME LIBRARY_NAME
GIT_REPO GIT_REPO
GIT_TAG GIT_TAG
CUSTOM_CMAKE
) )
set(multi_value_args PATCH_COMMAND TARGETS) set(multi_value_args PATCH_COMMAND TARGETS)
cmake_parse_arguments( cmake_parse_arguments(
@@ -121,6 +126,12 @@ if(NOT COMMAND FindOrFetch)
FetchContent_GetProperties(${_ARGS_LIBRARY_NAME}) FetchContent_GetProperties(${_ARGS_LIBRARY_NAME})
if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED}) if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED})
FetchContent_Populate(${_ARGS_LIBRARY_NAME}) FetchContent_Populate(${_ARGS_LIBRARY_NAME})
if(NOT "${_ARGS_CUSTOM_CMAKE}" STREQUAL "")
file(COPY
"${_ARGS_CUSTOM_CMAKE}"
DESTINATION "${${_ARGS_LIBRARY_NAME}_SOURCE_DIR}"
)
endif()
add_subdirectory( add_subdirectory(
${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR} ${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR}
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
@@ -156,6 +167,8 @@ endif()
# - ``PACKAGE_NAME`` name of the package. # - ``PACKAGE_NAME`` name of the package.
# - ``GIT_REPO`` git repository to fetch the library from. # - ``GIT_REPO`` git repository to fetch the library from.
# - ``GIT_TAG`` tag reference when fetching the library from the git repo. # - ``GIT_TAG`` tag reference when fetching the library from the git repo.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -170,7 +183,7 @@ if(NOT COMMAND FetchPackage)
cmake_parse_arguments( cmake_parse_arguments(
_ARGS _ARGS
"EXCLUDE_FROM_ALL" "EXCLUDE_FROM_ALL"
"PACKAGE_NAME;GIT_REPO;GIT_TAG" "PACKAGE_NAME;GIT_REPO;GIT_TAG;CUSTOM_CMAKE"
"PATCH_COMMAND;TARGETS" "PATCH_COMMAND;TARGETS"
${ARGN} ${ARGN}
) )
@@ -183,6 +196,7 @@ if(NOT COMMAND FetchPackage)
LIBRARY_NAME ${_ARGS_PACKAGE_NAME} LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
GIT_REPO ${_ARGS_GIT_REPO} GIT_REPO ${_ARGS_GIT_REPO}
GIT_TAG ${_ARGS_GIT_TAG} GIT_TAG ${_ARGS_GIT_TAG}
CUSTOM_CMAKE ${_ARGS_CUSTOM_CMAKE}
PATCH_COMMAND ${_ARGS_PATCH_COMMAND} PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
TARGETS ${_ARGS_TARGETS} TARGETS ${_ARGS_TARGETS}
USE_SYSTEM_PACKAGE OFF USE_SYSTEM_PACKAGE OFF
+15 -1
View File
@@ -23,6 +23,7 @@
# [LIBRARY_NAME [name]] # [LIBRARY_NAME [name]]
# [GIT_REPO [repo]] # [GIT_REPO [repo]]
# [GIT_TAG [tag]] # [GIT_TAG [tag]]
# [CUSTOM_CMAKE [path]]
# [PATCH_COMMAND [cmd] [args]] # [PATCH_COMMAND [cmd] [args]]
# [TARGETS [targets]] # [TARGETS [targets]]
# [EXCLUDE_FROM_ALL]) # [EXCLUDE_FROM_ALL])
@@ -42,6 +43,9 @@
# ``USE_SYSTEM_PACKAGE`` is ``ON``. # ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``GIT_TAG`` tag reference when fetching the library from the git # - ``GIT_TAG`` tag reference when fetching the library from the git
# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``. # repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository. Ignored if
# ``USE_SYSTEM_PACKAGE`` is ``ON``.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -70,6 +74,7 @@ if(NOT COMMAND FindOrFetch)
LIBRARY_NAME LIBRARY_NAME
GIT_REPO GIT_REPO
GIT_TAG GIT_TAG
CUSTOM_CMAKE
) )
set(multi_value_args PATCH_COMMAND TARGETS) set(multi_value_args PATCH_COMMAND TARGETS)
cmake_parse_arguments( cmake_parse_arguments(
@@ -121,6 +126,12 @@ if(NOT COMMAND FindOrFetch)
FetchContent_GetProperties(${_ARGS_LIBRARY_NAME}) FetchContent_GetProperties(${_ARGS_LIBRARY_NAME})
if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED}) if(NOT ${${_ARGS_LIBRARY_NAME}_POPULATED})
FetchContent_Populate(${_ARGS_LIBRARY_NAME}) FetchContent_Populate(${_ARGS_LIBRARY_NAME})
if(NOT "${_ARGS_CUSTOM_CMAKE}" STREQUAL "")
file(COPY
"${_ARGS_CUSTOM_CMAKE}"
DESTINATION "${${_ARGS_LIBRARY_NAME}_SOURCE_DIR}"
)
endif()
add_subdirectory( add_subdirectory(
${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR} ${${_ARGS_LIBRARY_NAME}_SOURCE_DIR} ${${_ARGS_LIBRARY_NAME}_BINARY_DIR}
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
@@ -156,6 +167,8 @@ endif()
# - ``PACKAGE_NAME`` name of the package. # - ``PACKAGE_NAME`` name of the package.
# - ``GIT_REPO`` git repository to fetch the library from. # - ``GIT_REPO`` git repository to fetch the library from.
# - ``GIT_TAG`` tag reference when fetching the library from the git repo. # - ``GIT_TAG`` tag reference when fetching the library from the git repo.
# - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
# fetching the library from the git repository.
# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an # - ``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 # update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
# for details on the parameter. # for details on the parameter.
@@ -170,7 +183,7 @@ if(NOT COMMAND FetchPackage)
cmake_parse_arguments( cmake_parse_arguments(
_ARGS _ARGS
"EXCLUDE_FROM_ALL" "EXCLUDE_FROM_ALL"
"PACKAGE_NAME;GIT_REPO;GIT_TAG" "PACKAGE_NAME;GIT_REPO;GIT_TAG;CUSTOM_CMAKE"
"PATCH_COMMAND;TARGETS" "PATCH_COMMAND;TARGETS"
${ARGN} ${ARGN}
) )
@@ -183,6 +196,7 @@ if(NOT COMMAND FetchPackage)
LIBRARY_NAME ${_ARGS_PACKAGE_NAME} LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
GIT_REPO ${_ARGS_GIT_REPO} GIT_REPO ${_ARGS_GIT_REPO}
GIT_TAG ${_ARGS_GIT_TAG} GIT_TAG ${_ARGS_GIT_TAG}
CUSTOM_CMAKE ${_ARGS_CUSTOM_CMAKE}
PATCH_COMMAND ${_ARGS_PATCH_COMMAND} PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
TARGETS ${_ARGS_TARGETS} TARGETS ${_ARGS_TARGETS}
USE_SYSTEM_PACKAGE OFF USE_SYSTEM_PACKAGE OFF