2323# [LIBRARY_NAME [name]]
2424# [GIT_REPO [repo]]
2525# [GIT_TAG [tag]]
26+ # [CUSTOM_CMAKE [path]]
2627# [PATCH_COMMAND [cmd] [args]]
2728# [TARGETS [targets]]
2829# [EXCLUDE_FROM_ALL])
4243# ``USE_SYSTEM_PACKAGE`` is ``ON``.
4344# - ``GIT_TAG`` tag reference when fetching the library from the git
4445# repository. Ignored if ``USE_SYSTEM_PACKAGE`` is ``ON``.
46+ # - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
47+ # fetching the library from the git repository. Ignored if
48+ # ``USE_SYSTEM_PACKAGE`` is ``ON``.
4549# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
4650# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
4751# for details on the parameter.
@@ -70,6 +74,7 @@ if(NOT COMMAND FindOrFetch)
7074 LIBRARY_NAME
7175 GIT_REPO
7276 GIT_TAG
77+ CUSTOM_CMAKE
7378 )
7479 set (multi_value_args PATCH_COMMAND TARGETS)
7580 cmake_parse_arguments (
@@ -121,6 +126,12 @@ if(NOT COMMAND FindOrFetch)
121126 FetchContent_GetProperties(${_ARGS_LIBRARY_NAME} )
122127 if (NOT ${${_ARGS_LIBRARY_NAME} _POPULATED})
123128 FetchContent_Populate(${_ARGS_LIBRARY_NAME} )
129+ if (NOT "${_ARGS_CUSTOM_CMAKE} " STREQUAL "" )
130+ file (COPY
131+ "${_ARGS_CUSTOM_CMAKE} "
132+ DESTINATION "${${_ARGS_LIBRARY_NAME} _SOURCE_DIR}"
133+ )
134+ endif ()
124135 add_subdirectory (
125136 ${${_ARGS_LIBRARY_NAME} _SOURCE_DIR} ${${_ARGS_LIBRARY_NAME} _BINARY_DIR}
126137 EXCLUDE_FROM_ALL
@@ -156,6 +167,8 @@ endif()
156167# - ``PACKAGE_NAME`` name of the package.
157168# - ``GIT_REPO`` git repository to fetch the library from.
158169# - ``GIT_TAG`` tag reference when fetching the library from the git repo.
170+ # - ``CUSTOM_CMAKE`` path to a custom CMakeLists.txt file to be used when
171+ # fetching the library from the git repository.
159172# - ``PATCH_COMMAND`` Specifies a custom command to patch the sources after an
160173# update. See https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add
161174# for details on the parameter.
@@ -170,7 +183,7 @@ if(NOT COMMAND FetchPackage)
170183 cmake_parse_arguments (
171184 _ARGS
172185 "EXCLUDE_FROM_ALL"
173- "PACKAGE_NAME;GIT_REPO;GIT_TAG"
186+ "PACKAGE_NAME;GIT_REPO;GIT_TAG;CUSTOM_CMAKE "
174187 "PATCH_COMMAND;TARGETS"
175188 ${ARGN}
176189 )
@@ -183,6 +196,7 @@ if(NOT COMMAND FetchPackage)
183196 LIBRARY_NAME ${_ARGS_PACKAGE_NAME}
184197 GIT_REPO ${_ARGS_GIT_REPO}
185198 GIT_TAG ${_ARGS_GIT_TAG}
199+ CUSTOM_CMAKE ${_ARGS_CUSTOM_CMAKE}
186200 PATCH_COMMAND ${_ARGS_PATCH_COMMAND}
187201 TARGETS ${_ARGS_TARGETS}
188202 USE_SYSTEM_PACKAGE OFF
0 commit comments