Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geogram boilerplate

Get you up and running with the Geogram library

Maintenance Level: Abandoned

CLI (apps/cli.cpp) GUI (apps/gui.cpp)

Requirements

Clone, build & run

1. Clone with submodules

git clone --recurse-submodules https://github.com/LIHPC-Computational-Geometry/geogram-boilerplate.git
cd geogram-boilerplate
If 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 build

3. Generate the Makefile and compile

cmake .. # the CMakeLists.txt is in the parent folder
make
To configure a release build, instead of a debug build

Add -DCMAKE_BUILD_TYPE=Release to the CMake command:

cmake .. -DCMAKE_BUILD_TYPE=Release
make

Better: create a build folder for each build type, like build_debug/ & build_release/, and update the .gitignore

To use Ninja instead of Make

Add -G Ninja to the CMake command:

cmake .. -G Ninja 
ninja

4. Execute

# for the command-line interface example
./cli

# for the graphical user interface example
./gui

Customize the project

  • Change the LICENSE
  • Rename the project in CMakeLists.txt (the project() directive)
  • Rename the executables. To do so, you have to rename the apps/*.cpp files, and update accordingly CMakeLists.txt directives add_executable(), target_include_directories() and target_link_libraries(). To rename the GUI window title, change the value passed to the SimpleMeshApplication constructor.
  • Delete the images/ folder
  • Overwrite this README

Update Geogram

cd ext/geogram
git pull
# then `git checkout ...` if you want to target a specific commit/version

Step-by-step project creation

If 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 main
4. 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.cpp with this file. Note the #include <geogram/*> directives.
  • Create include/shared.h and paste the content of this file
  • Create src/shared.cpp and paste the content of this file

Rebuild the project.

6. Create a GUI app
  • Create include/MyGui.h and paste the content of this file
  • Create src/MyGui.cpp and paste the content of this file
  • Create apps/gui.cpp and paste the content of this file
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.

Ressources

License

MIT-0

About

Get you up and running with the Geogram library

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Contributors

Languages