From abadb9438e4d7939c4deaed122cf0aefc7288159 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Wed, 8 Dec 2021 21:26:24 -0500
Subject: [PATCH] COMP: Update external project supporting setting a custom git
 repository and tag

This commit adds support for passing options like the following:
* iMSTK_<project-name>_GIT_REPOSITORY
* iMSTK_<project-name>_GIT_TAG

This approach enables:

* Streamline external project maintenance by allowing to develop patches
  directly in the source checkout downloaded by external project.

* Configuring the version of each external projects when integrating
  iMSTK in custom applications (e.g Slicer-based app).

Note that iMSTKData and VTK external projects have not been updated.
---
 CMake/External/External_Assimp.cmake      | 21 ++++++++++++--
 CMake/External/External_Eigen3.cmake      | 20 +++++++++++--
 CMake/External/External_GTest.cmake       | 20 +++++++++++--
 CMake/External/External_LibNiFalcon.cmake | 20 +++++++++++--
 CMake/External/External_OpenVR.cmake      | 21 ++++++++++++--
 CMake/External/External_PThreads.cmake    | 22 ++++++++++++---
 CMake/External/External_PhysX.cmake       | 20 +++++++++++--
 CMake/External/External_SFML.cmake        | 20 +++++++++++--
 CMake/External/External_TBB.cmake         | 34 ++++++++++++++++-------
 CMake/External/External_Uncrustify.cmake  | 19 +++++++++++--
 CMake/External/External_VRPN.cmake        | 15 ++++++++--
 CMake/External/External_VegaFEM.cmake     | 20 +++++++++++--
 CMake/External/External_g3log.cmake       | 21 ++++++++++++--
 Docs/Maintainance.md                      | 27 ++++++++++++++++--
 14 files changed, 253 insertions(+), 47 deletions(-)

diff --git a/CMake/External/External_Assimp.cmake b/CMake/External/External_Assimp.cmake
index cbca2e2e6..bcb924f04 100644
--- a/CMake/External/External_Assimp.cmake
+++ b/CMake/External/External_Assimp.cmake
@@ -2,10 +2,25 @@
 # Add External Project
 #-----------------------------------------------------------------------------
 include(imstkAddExternalProject)
-set(git_sha "fixCompilationError")
+
+# Download options
+if(NOT DEFINED iMSTK_Assimp_GIT_SHA)
+  set(iMSTK_Assimp_GIT_SHA "fixCompilationError")
+endif()
+if(NOT DEFINED iMSTK_Assimp_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/assimp/-/archive/${iMSTK_Assimp_GIT_SHA}/assimp-${iMSTK_Assimp_GIT_SHA}.zip
+    URL_HASH MD5=fab081af9dbd73a9a5c61cd33dd93340
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_Assimp_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_Assimp_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( Assimp
-  URL https://gitlab.kitware.com/iMSTK/assimp/-/archive/${git_sha}/assimp-${git_sha}.zip
-  URL_MD5 fab081af9dbd73a9a5c61cd33dd93340
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
     -DASSIMP_BUILD_ASSIMP_TOOLS:BOOL=OFF
diff --git a/CMake/External/External_Eigen3.cmake b/CMake/External/External_Eigen3.cmake
index e85820c41..7e32b4981 100644
--- a/CMake/External/External_Eigen3.cmake
+++ b/CMake/External/External_Eigen3.cmake
@@ -22,10 +22,24 @@ else()
     )
 endif()
 
-set(git_sha "3.4.0")
+# Download options
+if(NOT DEFINED iMSTK_Eigen3_GIT_SHA)
+  set(iMSTK_Eigen3_GIT_SHA "3.4.0")
+endif()
+if(NOT DEFINED iMSTK_Eigen3_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL "https://gitlab.kitware.com/iMSTK/eigen/-/archive/${iMSTK_Eigen3_GIT_SHA}/eigen-${iMSTK_Eigen3_GIT_SHA}.tar.gz"
+    URL_HASH MD5=4c527a9171d71a72a9d4186e65bea559
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_Eigen3_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_Eigen3_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( Eigen3
-  URL "https://gitlab.kitware.com/iMSTK/eigen/-/archive/${git_sha}/eigen-${git_sha}.tar.gz"
-  URL_HASH MD5=4c527a9171d71a72a9d4186e65bea559
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
         -DBUILD_TESTING:BOOL=OFF
         ${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
diff --git a/CMake/External/External_GTest.cmake b/CMake/External/External_GTest.cmake
index cafbe2f90..564a6ed61 100644
--- a/CMake/External/External_GTest.cmake
+++ b/CMake/External/External_GTest.cmake
@@ -2,9 +2,25 @@
 # Add External Project
 #-----------------------------------------------------------------------------
 include(imstkAddExternalProject)
+
+# Download options
+if(NOT DEFINED iMSTK_GTest_GIT_SHA)
+  set(iMSTK_GTest_GIT_SHA "40dfd4b775a66979ad1bd19321cdfd0feadfea27")
+endif()
+if(NOT DEFINED iMSTK_GTest_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://github.com/google/googletest/archive/${iMSTK_GTest_GIT_SHA}.zip
+    URL_HASH MD5=222793254ade8010fe6ff000f18c6b15
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_GTest_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_GTest_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( GTest
-   URL https://github.com/google/googletest/archive/40dfd4b775a66979ad1bd19321cdfd0feadfea27.zip
-   URL_MD5 222793254ade8010fe6ff000f18c6b15
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DBUILD_GMOCK:BOOL=ON
     -DBUILD_GTEST:BOOL=ON
diff --git a/CMake/External/External_LibNiFalcon.cmake b/CMake/External/External_LibNiFalcon.cmake
index 89a9a9564..1d9ab0a6e 100644
--- a/CMake/External/External_LibNiFalcon.cmake
+++ b/CMake/External/External_LibNiFalcon.cmake
@@ -6,11 +6,25 @@ if(WIN32)
   list(APPEND LIBNIFALCON_DEPENDENCIES "FTD2XX")
 endif(WIN32)
 
+# Download options
+if(NOT DEFINED iMSTK_LibNiFalcon_GIT_SHA)
+  set(iMSTK_LibNiFalcon_GIT_SHA "libusb1-windows")
+endif()
+if(NOT DEFINED iMSTK_LibNiFalcon_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/libnifalcon/-/archive/${iMSTK_LibNiFalcon_GIT_SHA}/libnifalcon-${iMSTK_LibNiFalcon_GIT_SHA}.zip
+    URL_HASH MD5=6d5d68c92837388bfcd27f99a48b921d
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_LibNiFalcon_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_LibNiFalcon_GIT_SHA}
+    )
+endif()
+
 include(imstkAddExternalProject)
-set(git_sha "libusb1-windows")
 imstk_add_external_project( LibNiFalcon
-  URL https://gitlab.kitware.com/iMSTK/libnifalcon/-/archive/${git_sha}/libnifalcon-${git_sha}.zip
-  URL_MD5 6d5d68c92837388bfcd27f99a48b921d
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DBUILD_TESTING:BOOL=OFF
     -DBUILD_EXAMPLES:BOOL=OFF
diff --git a/CMake/External/External_OpenVR.cmake b/CMake/External/External_OpenVR.cmake
index 8dd9b06dd..d7beeeaa0 100644
--- a/CMake/External/External_OpenVR.cmake
+++ b/CMake/External/External_OpenVR.cmake
@@ -60,10 +60,25 @@ endif()
 #-----------------------------------------------------------------------------
 # Add External Project
 #-----------------------------------------------------------------------------
-set(git_sha "v1.12.5")
+
+# Download options
+if(NOT DEFINED iMSTK_OpenVR_GIT_SHA)
+  set(iMSTK_OpenVR_GIT_SHA "v1.12.5")
+endif()
+if(NOT DEFINED iMSTK_OpenVR_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/openvr/-/archive/${iMSTK_OpenVR_GIT_SHA}/openvr-${iMSTK_OpenVR_GIT_SHA}.tar.gz
+    URL_HASH MD5=42c4d1c4a194860aaa4e793b009b99c0
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_OpenVR_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_OpenVR_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( OpenVR
-  URL "https://gitlab.kitware.com/iMSTK/openvr/-/archive/${git_sha}/openvr-${git_sha}.tar.gz"
-  URL_MD5 "42c4d1c4a194860aaa4e793b009b99c0"
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   DOWNLOAD_DIR ${OpenVR_PREFIX}
   SOURCE_DIR ${OpenVR_SOURCE_DIR}
   UPDATE_COMMAND ${SKIP_STEP_COMMAND}
diff --git a/CMake/External/External_PThreads.cmake b/CMake/External/External_PThreads.cmake
index 8d91ee4bb..6a97c0bd7 100644
--- a/CMake/External/External_PThreads.cmake
+++ b/CMake/External/External_PThreads.cmake
@@ -2,11 +2,25 @@
 # Add External Project
 #-----------------------------------------------------------------------------
 include(imstkAddExternalProject)
-set(git_sha "iMSTK")
+
+# Download options
+if(NOT DEFINED iMSTK_PThreads_GIT_SHA)
+  set(iMSTK_PThreads_GIT_SHA "iMSTK")
+endif()
+if(NOT DEFINED iMSTK_PThreads_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/libpthread/-/archive/${iMSTK_PThreads_GIT_SHA}/libpthread-${iMSTK_PThreads_GIT_SHA}.zip
+    URL_HASH MD5=9bc417d5ebb8ac0859eeb77a147569ba
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_PThreads_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_PThreads_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( PThreads
-  URL https://gitlab.kitware.com/iMSTK/libpthread/-/archive/${git_sha}/libpthread-${git_sha}.zip
-  URL_MD5 9bc417d5ebb8ac0859eeb77a147569ba
-  # This is the iMSTK branch
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DBUILD_TESTING:BOOL=OFF
   RELATIVE_INCLUDE_PATH "include"
diff --git a/CMake/External/External_PhysX.cmake b/CMake/External/External_PhysX.cmake
index 702dc6839..f3eff7839 100644
--- a/CMake/External/External_PhysX.cmake
+++ b/CMake/External/External_PhysX.cmake
@@ -58,10 +58,24 @@ set(PHYSX_iMSTK_INSTALL "${CMAKE_COMMAND}"
   -DiMSTK_INSTALL_DIR=${CMAKE_INSTALL_PREFIX}
   -P ${CMAKE_SOURCE_DIR}/CMake/External/Patches/physx.cmake)
 
-set(git_sha "b03d0a74c1244a97b83dea58dc201beeacd45cf4")
+# Download options
+if(NOT DEFINED iMSTK_PhysX_GIT_SHA)
+  set(iMSTK_PhysX_GIT_SHA "b03d0a74c1244a97b83dea58dc201beeacd45cf4")
+endif()
+if(NOT DEFINED iMSTK_PhysX_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/PhysX/-/archive/${iMSTK_PhysX_GIT_SHA}/PhysX-${iMSTK_PhysX_GIT_SHA}.zip
+    URL_HASH MD5=9c17263ceec705eaf1ddd7c2ee796bac
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_PhysX_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_PhysX_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( PhysX
-  URL https://gitlab.kitware.com/iMSTK/PhysX/-/archive/${git_sha}/PhysX-${git_sha}.zip
-  URL_MD5 9c17263ceec705eaf1ddd7c2ee796bac
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   SOURCE_SUBDIR ./physx/compiler/public
   CMAKE_CACHE_ARGS
     -DPHYSX_CXX_FLAGS:STRING=${NO_MEMSET}
diff --git a/CMake/External/External_SFML.cmake b/CMake/External/External_SFML.cmake
index fd54e7fba..c285b0f77 100644
--- a/CMake/External/External_SFML.cmake
+++ b/CMake/External/External_SFML.cmake
@@ -1,10 +1,26 @@
 #-----------------------------------------------------------------------------
 # Add SFML External Project
 #-----------------------------------------------------------------------------
+
+# Download options
+if(NOT DEFINED iMSTK_SFML_GIT_SHA)
+  set(iMSTK_SFML_GIT_SHA "2.4.2")
+endif()
+if(NOT DEFINED iMSTK_SFML_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://github.com/SFML/SFML/archive/${iMSTK_SFML_GIT_SHA}.zip
+    URL_HASH MD5=b2e2cf6c43e9d2b578c4abd9aa28a6aa
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_SFML_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_SFML_GIT_SHA}
+    )
+endif()
+
 include(imstkAddExternalProject)
 imstk_add_external_project( SFML
-  URL https://github.com/SFML/SFML/archive/2.4.2.zip
-  URL_MD5 b2e2cf6c43e9d2b578c4abd9aa28a6aa
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DSFML_BUILD_AUDIO:BOOL=ON
     -DSFML_BUILD_GRAPHICS:BOOL=OFF
diff --git a/CMake/External/External_TBB.cmake b/CMake/External/External_TBB.cmake
index e2e855b0e..3e0ad81ac 100644
--- a/CMake/External/External_TBB.cmake
+++ b/CMake/External/External_TBB.cmake
@@ -67,20 +67,34 @@ endif()
 #-----------------------------------------------------------------------------
 include(imstkAddExternalProject)
 
-if(WIN32)
-  set(tbb_file "tbb${TBB_VER}_win.zip")
-  set(tbb_md5 "a061a7c9821a374023201e8592860730")
-elseif(APPLE)
-  set(tbb_file "tbb${TBB_VER}_mac.tgz")
-  set(tbb_md5 "43a0d6409317ee94f047622fd489a6c8")
+# Download options
+if(NOT DEFINED iMSTK_TBB_GIT_SHA)
+  set(iMSTK_TBB_GIT_SHA "2019_U9")
+endif()
+if(NOT DEFINED iMSTK_TBB_GIT_REPOSITORY)
+  if(WIN32)
+    set(tbb_file "tbb${TBB_VER}_win.zip")
+    set(tbb_md5 "a061a7c9821a374023201e8592860730")
+  elseif(APPLE)
+    set(tbb_file "tbb${TBB_VER}_mac.tgz")
+    set(tbb_md5 "43a0d6409317ee94f047622fd489a6c8")
+  else()
+    set(tbb_file "tbb${TBB_VER}_lin.tgz")
+    set(tbb_md5 "b5025847fa47040b4d2da8d6bdba0224")
+  endif()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://github.com/oneapi-src/oneTBB/releases/download/${iMSTK_TBB_GIT_SHA}/${tbb_file}
+    URL_HASH MD5=${tbb_md5}
+    )
 else()
-  set(tbb_file "tbb${TBB_VER}_lin.tgz")
-  set(tbb_md5 "b5025847fa47040b4d2da8d6bdba0224")
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_TBB_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_TBB_GIT_SHA}
+    )
 endif()
 
 imstk_add_external_project(TBB
-  URL https://github.com/oneapi-src/oneTBB/releases/download/2019_U9/${tbb_file}
-  URL_MD5 ${tbb_md5}
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   DOWNLOAD_DIR ${TBB_PREFIX}
   SOURCE_DIR ${TBB_SOURCE_DIR}
   UPDATE_COMMAND ${SKIP_STEP_COMMAND}
diff --git a/CMake/External/External_Uncrustify.cmake b/CMake/External/External_Uncrustify.cmake
index f50fa8dbf..139ddb614 100644
--- a/CMake/External/External_Uncrustify.cmake
+++ b/CMake/External/External_Uncrustify.cmake
@@ -2,10 +2,25 @@
 # Add External Project
 #-----------------------------------------------------------------------------
 
+# Download options
+if(NOT DEFINED iMSTK_Uncrustify_GIT_SHA)
+  set(iMSTK_Uncrustify_GIT_SHA "0.70.1")
+endif()
+if(NOT DEFINED iMSTK_Uncrustify_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://github.com/uncrustify/uncrustify/archive/uncrustify-${iMSTK_Uncrustify_GIT_SHA}.zip
+    URL_HASH MD5=0f6bd2ca1a35efebac3bc8aee44f6532
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_Uncrustify_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_Uncrustify_GIT_SHA}
+    )
+endif()
+
 include(imstkAddExternalProject)
 imstk_add_external_project( Uncrustify
-  URL https://github.com/uncrustify/uncrustify/archive/uncrustify-0.70.1.zip
-  URL_MD5 0f6bd2ca1a35efebac3bc8aee44f6532
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
   RELATIVE_INCLUDE_PATH ""
   DEPENDENCIES ""
diff --git a/CMake/External/External_VRPN.cmake b/CMake/External/External_VRPN.cmake
index fca3845c2..be534fa52 100644
--- a/CMake/External/External_VRPN.cmake
+++ b/CMake/External/External_VRPN.cmake
@@ -31,10 +31,19 @@ endif()
 #-----------------------------------------------------------------------------
 # Add External Project
 #-----------------------------------------------------------------------------
+
+# Download options
+if(NOT DEFINED iMSTK_VRPN_GIT_SHA)
+  set(iMSTK_VRPN_GIT_SHA "7a2845e4b1be2707ccb67dd1d388fb22a766e8f7") # vrpn-imstk-additions
+endif()
+if(NOT DEFINED iMSTK_VRPN_GIT_REPOSITORY)
+  set(iMSTK_VRPN_GIT_REPOSITORY "https://gitlab.kitware.com/iMSTK/vrpn.git")
+endif()
+
 include(imstkAddExternalProject)
 imstk_add_external_project( VRPN
-  GIT_REPOSITORY https://gitlab.kitware.com/iMSTK/vrpn.git
-  GIT_TAG 7a2845e4b1be2707ccb67dd1d388fb22a766e8f7 # vrpn-imstk-additions
+  GIT_REPOSITORY ${iMSTK_VRPN_GIT_REPOSITORY}
+  GIT_TAG ${iMSTK_VRPN_GIT_SHA}
   # Cannot get a zip as vrpn uses submodules which are not pulled into the zip
   CMAKE_CACHE_ARGS
     -DBUILD_TESTING:BOOL=OFF
@@ -55,4 +64,4 @@ imstk_add_external_project( VRPN
   DEPENDENCIES ${VRPN_DEPENDENCIES}
   RELATIVE_INCLUDE_PATH ""
   #VERBOSE
-)
\ No newline at end of file
+)
diff --git a/CMake/External/External_VegaFEM.cmake b/CMake/External/External_VegaFEM.cmake
index 8930025ef..ede98b6a5 100644
--- a/CMake/External/External_VegaFEM.cmake
+++ b/CMake/External/External_VegaFEM.cmake
@@ -27,10 +27,24 @@ else()
     )
 endif()
 
-set(git_sha "build_model_reduction")
+# Download options
+if(NOT DEFINED iMSTK_VegaFEM_GIT_SHA)
+  set(iMSTK_VegaFEM_GIT_SHA "build_model_reduction")
+endif()
+if(NOT DEFINED iMSTK_VegaFEM_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/vegafemv4.0/-/archive/${iMSTK_VegaFEM_GIT_SHA}/vegafemv4.0-${iMSTK_VegaFEM_GIT_SHA}.zip
+    URL_HASH MD5=3f04bb7c2ba080785bcadf44d1a462a3
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_VegaFEM_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_VegaFEM_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( VegaFEM
-  URL https://gitlab.kitware.com/iMSTK/vegafemv4.0/-/archive/${git_sha}/vegafemv4.0-${git_sha}.zip
-  URL_MD5 3f04bb7c2ba080785bcadf44d1a462a3
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DVegaFEM_ENABLE_PTHREADS_SUPPORT:BOOL=ON
     -DVegaFEM_ENABLE_OpenGL_SUPPORT:BOOL=OFF
diff --git a/CMake/External/External_g3log.cmake b/CMake/External/External_g3log.cmake
index 40de953cd..4630295be 100644
--- a/CMake/External/External_g3log.cmake
+++ b/CMake/External/External_g3log.cmake
@@ -38,10 +38,25 @@ set(g3log_INSTALL_COMMAND
 #-----------------------------------------------------------------------------
 # Add External Project
 #-----------------------------------------------------------------------------
-set(git_sha "6c1698c4f7db6b9e4246ead38051f9866ea3ac06")
+
+# Download options
+if(NOT DEFINED iMSTK_g3log_GIT_SHA)
+  set(iMSTK_g3log_GIT_SHA "6c1698c4f7db6b9e4246ead38051f9866ea3ac06")
+endif()
+if(NOT DEFINED iMSTK_g3log_GIT_REPOSITORY)
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    URL https://gitlab.kitware.com/iMSTK/g3log/-/archive/${iMSTK_g3log_GIT_SHA}/g3log-${iMSTK_g3log_GIT_SHA}.zip
+    URL_HASH MD5=3815bbfec2ff51dc473063c35eec0f36
+    )
+else()
+  set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+    GIT_REPOSITORY ${iMSTK_g3log_GIT_REPOSITORY}
+    GIT_TAG ${iMSTK_g3log_GIT_SHA}
+    )
+endif()
+
 imstk_add_external_project( g3log
-  URL https://gitlab.kitware.com/iMSTK/g3log/-/archive/${git_sha}/g3log-${git_sha}.zip
-  URL_MD5 3815bbfec2ff51dc473063c35eec0f36
+  ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
   CMAKE_CACHE_ARGS
     -DADD_FATAL_EXAMPLE:BOOL=OFF
   ${g3log_INSTALL_COMMAND}
diff --git a/Docs/Maintainance.md b/Docs/Maintainance.md
index 1173e387b..1bcb8e22b 100644
--- a/Docs/Maintainance.md
+++ b/Docs/Maintainance.md
@@ -67,9 +67,30 @@ Additionally to enable CMake to find the library correctly _if_ the library alre
 You will need to create this file which describes what files to download from where and how to build them to support your new library in the superbuild. In general this will mean customizing `imstk_add_external_project`.
 
     include(imstkAddExternalProject)
-	imstk_add_external_project(NewLib
-	  ....
-	)
+
+    # Download options
+    if(NOT DEFINED iMSTK_NewLib_GIT_SHA)
+      set(iMSTK_NewLib_GIT_SHA "...")
+    endif()
+    if(NOT DEFINED iMSTK_NewLib_GIT_REPOSITORY)
+      set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+        URL https://gitlab.kitware.com/iMSTK/newlib/-/archive/${iMSTK_NewLib_GIT_SHA}/newlib-${iMSTK_NewLib_GIT_SHA}.zip
+        URL_HASH MD5=...
+        )
+    else()
+      set(EXTERNAL_PROJECT_DOWNLOAD_OPTIONS
+        GIT_REPOSITORY ${iMSTK_NewLib_GIT_REPOSITORY}
+        GIT_TAG ${iMSTK_NewLib_GIT_SHA}
+        )
+    endif()
+
+    imstk_add_external_project(NewLib
+      ${EXTERNAL_PROJECT_DOWNLOAD_OPTIONS}
+      CMAKE_CACHE_ARGS
+        ...
+      DEPENDENCIES ${NewLib_DEPENDENCIES}
+      ...
+    )
 
 and customizing the build options for the new library by passing them via the `CMAKE_CACHE_ARGS` section. e.g.
 
-- 
GitLab