[CMake] Prevent ExternalProject from updating git submodules

Tim Rae timothy.rae at sbibits.com
Mon Oct 24 21:52:12 EDT 2016


Hi all,

I'm using ExternalProject_Add to add the popular C++ library range-v3 to 
one of our projects. However, since the build server only has local 
intranet access, and therefore can't access the main github repository, 
we have put a clone of that repo on our local gitlab:

ExternalProject_Add(range-v3
     PREFIX ${PREFIX_DIR}
     GIT_REPOSITORY ${LOCAL_GITLAB_URI}
)

The problem is that range-v3 has a documentation submodule that points 
to github, so `git clone ${LOCAL_GITLAB_URI} --recursive` would fail 
when github is inaccessible, whereas git clone works fine without the 
recursive flag.

I found a previous message from Tim Gallagher on the mailing list 
reporting the same problem, but it looks like the issue was never 
addressed upstream.

https://cmake.org/pipermail/cmake/2015-March/060100.html

Unfortunately, specifying GIT_SUBMODULES "" will add all submodules, so 
it doesn't appear that variable will help to solve the issue. I would 
suggest either having a special value like "__NONE__", or having a new 
boolean variable like INIT_GIT_SUBMODULES; either of which can be used 
to disable the automatic initialization of submodules entirely.

You could also change the default to NOT pull in submodules. This would 
be much better IMHO, as the current behavior is unintuitive. Most 
developers (e.g. myself until yesterday) don't even know what a 
submodule is, and are only familiar with using git clone, as opposed to 
git clone --recursive. Obviously this would be a breaking change though, 
so I understand that you probably don't want to go with this option.

For now I have "solved" the problem by adding a new commit to our 
range-v3 fork removing all git submodules, however this makes it more 
difficult to get the upstream changes in, so I highly recommend adding 
an option to disable the automatic initialization of git submodules.

Best regards,
Tim

-- 
*This correspondence (including any attachments) is for the intended 
recipient(s) only. It may contain confidential or privileged information or 
both. No confidentiality or privilege is waived or lost by any 
mis-transmission. If you receive this correspondence by mistake, please 
contact the sender immediately, delete this correspondence (and all 
attachments) and destroy any hard copies. You must not use, disclose, copy, 
distribute or rely on any part of this correspondence (including any 
attachments) if you are not the intended recipient(s). 本 
メッセージに記載および添付されている情報 (以 下、総称して「本情報」といいます。)は、本来の受信者による使用のみを 意 図しています。誤送信等により 
本 情報を取得された場合でも、本情報に係る 秘 密、または法律上の秘匿特権が失われるものではありません。本電子メールを 受 取られた方が、本来の受 
信者ではない場合には、本情報及びそのコピー すべ てを削除・破棄し、本電子メールが誤って届い た旨を発信者宛てにご通知下さい ま すようお願いしま 
す。本情報の閲覧、発信または本情報に基づく いかなる行 為も明確に禁止されていることをご了承くださ い。*


More information about the CMake mailing list