libigl
libigl copied to clipboard
Bug / Feature request: LIBIGL_MODULE_XXX=OFF still triggers FetchContent for optional dependencies
Describe the bug
When setting optional modules to OFF via -DLIBIGL_MODULE_EMBREE=OFF (or tetgen, triangle etc.), libigl still includes that module's CMake script and runs FetchContent.
CMake will try to clone the dependency repository from GitHub, even though the module is disabled and will not be compiled at all.
This is problematic in environments with limited/no GitHub network access (e.g. Termux on Android). The configure step fails because git clone cannot complete.
Feature request
- When
LIBIGL_MODULE_XXX=OFF, skip including that module and its external dependency CMake entirely, so FetchContent will not be executed. - Add a global option to try
find_package()to use system‑installed libraries before falling back to FetchContent, instead of hardcoding FetchContent only in recipes/external scripts.
To reproduce
- Clone libigl main branch
- Create build folder
- Run cmake:
cmake .. \
-DLIBIGL_BUILD_TESTS=OFF \
-DLIBIGL_MODULE_CORE=ON \
-DLIBIGL_MODULE_EMBREE=OFF \
-DLIBIGL_MODULE_TETGEN=OFF
4. CMake will attempt to clone embree via FetchContent, even though embree module is OFF.
Expected behavior
If module is disabled, its external dependencies should not be fetched at configure time.
Environment
Platform: Termux (Android ARM64)
CMake: 4.4
Compiler: Clang
libigl: main branch
log
21:14:09.232319 run-command.c:677 trace: run_command: git-remote-https origin https://github.com/embree/embree.git
21:14:09.232394 run-command.c:769 trace: start_command: /data/data/com.termux/files/usr/libexec/git-core/git-remote-https origin https://github.com/embree/embree.git
21:14:11.460482 run-command.c:677 trace: run_command: git --shallow-file /data/data/com.termux/files/home/libigl/build/_deps/embree-src/.git/shallow.lock index-pack --stdin --fix-thin '--keep=fetch-pack 31614 on localhost'
21:14:11.460572 run-command.c:769 trace: start_command: /data/data/com.termux/files/usr/libexec/git-core/git --shallow-file /data/data/com.termux/files/home/libigl/build/_deps/embree-src/.git/shallow.lock index-pack --stdin --fix-thin '--keep=fetch-pack 31614 on localhost'
21:14:11.472483 git.c:502 trace: built-in: git index-pack --stdin --fix-thin '--keep=fetch-pack 31614 on localhost'
error: RPC failed; curl 56 Recv failure: Software caused connection abort
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
21:14:13.883585 git.c:502 trace: built-in: git clone --no-checkout --depth 1 --no-single-branch --config advice.detachedHead=false https://github.com/embree/embree.git embree-src
Cloning into 'embree-src'...
21:14:13.893159 run-command.c:677 trace: run_command: git remote-https origin https://github.com/embree/embree.git
21:14:13.893202 run-command.c:769 trace: start_command: /data/data/com.termux/files/usr/libexec/git-core/git remote-https origin https://github.com/embree/embree.git
21:14:13.910144 git.c:811 trace: exec: git-remote-https origin https://github.com/embree/embree.git
21:14:13.910360 run-command.c:677 trace: run_command: git-remote-https origin https://github.com/embree/embree.git
21:14:13.910389 run-command.c:769 trace: start_command: /data/data/com.termux/files/usr/libexec/git-core/git-remote-https origin https://github.com/embree/embree.git
fatal: unable to access 'https://github.com/embree/embree.git/': Failed to connect to github.com:443 after 5 ms: Could not connect to server
Had to git clone more than once: 3 times.
CMake Error at embree-subbuild/embree-populate-prefix/tmp/embree-populate-gitclone.cmake:55 (message):
Failed to clone repository:
'https://github.com/embree/embree.git'
FAILED: [code=1] embree-populate-prefix/src/embree-populate-stamp/embree-populate-download /data/data/com.termux/files/home/libigl/build/_deps/embree-subbuild/embree-populate-prefix/src/embree-populate-stamp/embree-populate-download
cd /data/data/com.termux/files/home/libigl/build/_deps && /data/data/com.termux/files/usr/bin/cmake -DCMAKE_MESSAGE_LOG_LEVEL=VERBOSE -P /data/data/com.termux/files/home/libigl/build/_deps/embree-subbuild/embree-populate-prefix/tmp/embree-populate-gitclone.cmake && /data/data/com.termux/files/usr/bin/cmake -E touch /data/data/com.termux/files/home/libigl/build/_deps/embree-subbuild/embree-populate-prefix/src/embree-populate-stamp/embree-populate-download
ninja: build stopped: subcommand failed.
CMake Error at /data/data/com.termux/files/usr/share/cmake-4.4/Modules/FetchContent.cmake:1933 (message):
Build step for embree failed: 1
Call Stack (most recent call first):
/data/data/com.termux/files/usr/share/cmake-4.4/Modules/FetchContent.cmake:1622 (__FetchContent_populateSubbuild)
/data/data/com.termux/files/usr/share/cmake-4.4/Modules/FetchContent.cmake:2160:EVAL:2 (__FetchContent_doPopulation)
/data/data/com.termux/files/usr/share/cmake-4.4/Modules/FetchContent.cmake:2160 (cmake_language)
/data/data/com.termux/files/usr/share/cmake-4.4/Modules/FetchContent.cmake:2401 (__FetchContent_Populate)
cmake/recipes/external/embree.cmake:24 (FetchContent_MakeAvailable)
cmake/igl/modules/embree.cmake:17 (include)
cmake/igl/igl_include.cmake:32 (include)
cmake/igl/igl_include.cmake:43 (_igl_include_full)
cmake/libigl.cmake:17 (igl_include_optional)
CMakeLists.txt:161 (include)
-- Configuring incomplete, errors occurred!
~/libigl/build $