https://github.com/libigl/libigl-example-project
A blank project example showing how to use libigl and cmake.
https://github.com/libigl/libigl-example-project
Last synced: 5 months ago
JSON representation
A blank project example showing how to use libigl and cmake.
- Host: GitHub
- URL: https://github.com/libigl/libigl-example-project
- Owner: libigl
- License: mpl-2.0
- Created: 2015-12-02T21:33:39.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-08-22T13:40:34.000Z (10 months ago)
- Last Synced: 2025-08-22T15:40:53.040Z (10 months ago)
- Language: CMake
- Size: 63.5 KB
- Stars: 154
- Watchers: 9
- Forks: 128
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libigl example project
A blank project example showing how to use libigl and cmake. Feel free and
encouraged to copy or fork this project as a way of starting a new personal
project using libigl.
## Compile
Compile this project using the standard cmake routine:
mkdir build
cd build
cmake ..
make
This should find and build the dependencies and create a `example` binary.
## Run
From within the `build` directory just issue:
./example
A glfw app should launch displaying a 3D cube.
## Using other modules of libigl
This example project uses the `igl::opengl::glfw::Viewer`, therefore it requires
the glfw module of libigl. This shows up in the CMakeLists.txt
```cmake
igl_include(glfw)
…
target_link_libraries(${PROJECT_NAME} PUBLIC igl::glfw)
```
Suppose you also wanted to use the triangle module in libigl. Then you would
change these to
```cmake
igl_include(glfw)
igl_include(restricted triangle)
…
target_link_libraries(${PROJECT_NAME} PUBLIC igl::glfw igl_restricted::triangle)
```
The "restricted" appears in this case because the triangle library has a more
restricted license than libigl. See other examples commented out in
CMakeLists.txt.
## Dependencies
The only dependencies are STL, Eigen, [libigl](http://libigl.github.io/libigl/) and the dependencies
of the `igl::opengl::glfw::Viewer` (OpenGL, glad and GLFW).
The CMake build system will automatically download libigl and its dependencies using
[CMake FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html),
thus requiring no setup on your part.
### Use a local copy of libigl
You can use the CMake cache variable `FETCHCONTENT_SOURCE_DIR_LIBIGL` when configuring your CMake project for
the first time to aim it at a local copy of libigl instead.
```
cmake -DFETCHCONTENT_SOURCE_DIR_LIBIGL= ..
```
When changing this value, do not forget to clear your `CMakeCache.txt`, or to update the cache variable
via `cmake-gui` or `ccmake`.