ament / ament_cmake

Supporting CMake packages for working with ament
Apache License 2.0
97 stars 121 forks source link

ament_vendor should be able to use mirror site of git #473

Open felixf4xu opened 1 year ago

felixf4xu commented 1 year ago

In Ros2, ament_vendor is mainly used like this:

ament_vendor(assimp_vendor
  SATISFIED ${assimp_FOUND}
  VCS_URL https://github.com/assimp/assimp.git
  VCS_VERSION v5.2.2
  CMAKE_ARGS
    -DASSIMP_BUILD_ASSIMP_TOOLS:BOOL=OFF
    -DASSIMP_BUILD_TESTS:BOOL=OFF
    -DASSIMP_BUILD_SAMPLES:BOOL=OFF
    "${ASSIMP_CMAKE_FLAGS}"
    "-DCMAKE_CXX_FLAGS=${ASSIMP_CXX_FLAGS}"
  PATCHES patches
)

and VCS_URL https://github.com/assimp/assimp.git is usually hardcoded.

When a mirror site of github is needed to build ros2, it's very difficult to set the mirror site URL unless the source code is modified.

I'm proposing an updated version of macro ament_vendor so that it can use env variable (if set) as a prioritized value of VCS_URL.

As a result, for all the xxxxx_vendor projects, it's not necessary to touch the source code of VCS_URL but to set an environmental value of assimp_vendor_VCS_URL in my case and use the mirror git site.

Any comment? I can create a PR for it.

sloretz commented 1 year ago

Upstream CMake had an issue for this: https://gitlab.kitware.com/cmake/cmake/-/issues/22688 . It looks like they closed it in favor of git's url.<base>.insteadOf: https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf

Would that work for your use case?

felixf4xu commented 1 year ago

My original idea is close to the cmake issue. The git config solution is very limited for some very specific cases.

If cmake is not planning to do it, will ament_cmake do it? (Please see also my other comment https://github.com/ament/ament_cmake/pull/474#issuecomment-1628927181)