Get you up and running with the Geogram library
| CLI (apps/cli.cpp) | GUI (apps/gui.cpp) |
|---|---|
![]() |
![]() |
- Git
- CMake
- a C++ 20 compiler discoverable by CMake
- potential platform-specific requirements inherited from Geogram: Linux, Windows, macOS, Emscripten
1. Clone with submodules
git clone --recurse-submodules https://github.com/LIHPC-Computational-Geometry/geogram-boilerplate.git
cd geogram-boilerplateIf you forgot --recurse-submodules
# inside the geogram-boilerplate repo
git submodule init
git submodule update
cd ext/geogram
git submodule init
git submodule update
cd ../..See https://git-scm.com/book/en/v2/Git-Tools-Submodules#_cloning_submodules
2. Create a build directory
mkdir build
cd build3. Generate the Makefile and compile
cmake .. # the CMakeLists.txt is in the parent folder
makeTo configure a release build, instead of a debug build
Add -DCMAKE_BUILD_TYPE=Release to the CMake command:
cmake .. -DCMAKE_BUILD_TYPE=Release
makeBetter: create a build folder for each build type, like build_debug/ & build_release/, and update the .gitignore
4. Execute
# for the command-line interface example
./cli
# for the graphical user interface example
./gui- Change the LICENSE
- Rename the project in CMakeLists.txt (the
project()directive) - Rename the executables. To do so, you have to rename the
apps/*.cppfiles, and update accordingly CMakeLists.txt directivesadd_executable(),target_include_directories()andtarget_link_libraries(). To rename the GUI window title, change the value passed to theSimpleMeshApplicationconstructor. - Delete the images/ folder
- Overwrite this README
cd ext/geogram
git pull
# then `git checkout ...` if you want to target a specific commit/versionIf you want to add Geogram to an existing project, you may find useful this step-by-step guide to recreate this boilerplate repo.
1. Hello world in C++
Create apps/cli.cpp:
#include <iostream>
using namespace GEO;
int main(int argc, char** argv) {
std::cout << "Hello world!" << std::endl;
return 0;
}2. Basic CMakeLists.txt
Create CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(boilerplate-geogram)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#################
# EXECUTABLES
#################
add_executable(cli apps/cli.cpp)See the beginning of the README on how to build and run the program.
3. Add Geogram as submodule
mkdir ext
cd ext
git submodule add https://github.com/BrunoLevy/geogram.git # or use the SSH URL
cd geogram
git submodule init
git submodule update
git checkout main4. Update CMakeLists.txt for Geogram and a static library
cmake_minimum_required(VERSION 3.5)
project(boilerplate-geogram)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+#################
+# DEPENDENCIES
+#################
+# Geogram
+set(GEOGRAM_LIB_ONLY ON)
+set(GEOGRAM_SOURCE_DIR "${CMAKE_SOURCE_DIR}/ext/geogram/" CACHE PATH "full path to the Geogram installation")
+include(${CMAKE_SOURCE_DIR}/ext/geogram/cmake/geo_detect_platform.cmake) # detect compilation target & autofill VORPALINE_PLATFORM
+add_subdirectory(ext/geogram)
+set(EXTERNAL_LIBS
+ geogram
+ geogram_gfx
+)
+#################
+# LIBRARY
+#################
+set(SRCFILES
+ src/shared.cpp
+)
+add_library(lib STATIC ${SRCFILES})
+target_include_directories(lib PRIVATE include)
+target_link_libraries(lib PRIVATE ${EXTERNAL_LIBS})
#################
# EXECUTABLES
#################
add_executable(cli apps/cli.cpp)
+target_include_directories(cli PRIVATE include)
+target_link_libraries(cli PRIVATE lib ${EXTERNAL_LIBS})5. Use the Geogram library inside the executable
- Replace the content of
apps/cli.cppwith this file. Note the#include <geogram/*>directives. - Create
include/shared.hand paste the content of this file - Create
src/shared.cppand paste the content of this file
Rebuild the project.
6. Create a GUI app
7. Update CMakeLists.txt for the new executable
# [...]
#################
# LIBRARY
#################
+set(SRCFILES
src/shared.cpp
+ src/MyGui.cpp
)
add_library(lib STATIC ${SRCFILES})
target_include_directories(lib PRIVATE include)
target_link_libraries(lib PRIVATE ${EXTERNAL_LIBS})
#################
# EXECUTABLES
#################
add_executable(cli apps/cli.cpp)
target_include_directories(cli PRIVATE include)
target_link_libraries(cli PRIVATE lib ${EXTERNAL_LIBS})
+add_executable(gui apps/gui.cpp)
+target_include_directories(gui PRIVATE include)
+target_link_libraries(gui PRIVATE lib ${EXTERNAL_LIBS})Then rebuild the project.
- Geogram's documentation, in particular for GUIs the Applications page
- The source code of Geogram's examples

