Skip to content

Commit

Permalink
Add script for vcpkg
Browse files Browse the repository at this point in the history
* modified to accept params from command arguments
* fix for cmake module for different syntax in windows
  • Loading branch information
tzukpolinsky authored and RainerKuemmerle committed Jul 1, 2023
1 parent b71540c commit dffe953
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 16 deletions.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Linux/Mac: [![CI](https://github.com/RainerKuemmerle/g2o/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/RainerKuemmerle/g2o/actions/workflows/ci.yml)
Windows: [![win64](https://github.com/RainerKuemmerle/g2o/actions/workflows/windows.yml/badge.svg?event=push)](https://github.com/RainerKuemmerle/g2o/actions/workflows/windows.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/280c5eed95ed4059ad5d003d59e72704)](https://www.codacy.com/gh/RainerKuemmerle/g2o/dashboard?utm_source=github.com&utm_medium=referral&utm_content=RainerKuemmerle/g2o&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/280c5eed95ed4059ad5d003d59e72704)](https://www.codacy.com/gh/RainerKuemmerle/g2o/dashboard?utm_source=github.com&utm_medium=referral&utm_content=RainerKuemmerle/g2o&utm_campaign=Badge_Grade)

g2o is an open-source C++ framework for optimizing graph-based nonlinear error
functions. g2o has been designed to be easily extensible to a wide range of
Expand All @@ -24,6 +24,7 @@ implementations of state-of-the-art approaches for the specific problems
(02/2011).

## Python and updated memory management

The branch [pymem](https://github.com/RainerKuemmerle/g2o/tree/pymem) contains a python wrapper and switches to smart pointer instead of RAW pointers.
It is currently experimental but PRs and improvements are welcome - as always.

Expand Down Expand Up @@ -76,14 +77,14 @@ See the doc folder for the full text of the licenses.

g2o is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
licenses for more details.

## Requirements

- C++17 compiler (CI pipeline runs with gcc, clang and MSVC)
- cmake <http://www.cmake.org>
- Eigen3 <http://eigen.tuxfamily.org>
- cmake <http://www.cmake.org>
- Eigen3 <http://eigen.tuxfamily.org>

On Ubuntu / Debian these dependencies are resolved by installing the
following packages.
Expand All @@ -93,10 +94,10 @@ following packages.

### Optional requirements

- spdlog <https://github.com/gabime/spdlog>
- suitesparse <http://faculty.cse.tamu.edu/davis/suitesparse.html>
- Qt5 <http://qt-project.org>
- libQGLViewer <http://www.libqglviewer.com>
- spdlog <https://github.com/gabime/spdlog>
- suitesparse <http://faculty.cse.tamu.edu/davis/suitesparse.html>
- Qt5 <http://qt-project.org>
- libQGLViewer <http://www.libqglviewer.com>

On Ubuntu / Debian these dependencies are resolved by installing the
following packages.
Expand All @@ -121,7 +122,14 @@ If using [vcpkg](https://github.com/Microsoft/vcpkg), then

`script\install-deps-windows.bat`

will build and install the required dependencies. The location of `vcpkg` and required triplet are determined by the environment variables `VCPKG_ROOT_DIR` and `VCPKG_DEFAULT_TRIPLET`.
or for full dependencies installation

`script\install-additional-deps-windows.bat`

will build and install the dependencies. The location of `vcpkg` and required
triplet can be passed as cli arguments respectively. Note that usually vcpkg
will auto detect the triplet. Set it only if your are not using the default
build for your OS.

## Compilation

Expand All @@ -138,18 +146,19 @@ by the following command sequence.
The binaries will be placed in bin and the libraries in lib which
are both located in the top-level folder.

On Windows with `vcpkg` the following two commands will generate build scripts for Visual Studio 2017 MSVC 15 tool set (please change the Visual Studio version number in accordance with your system):
On Windows with `vcpkg` the following commands will generate build scripts (please change the Visual Studio version number in accordance with your system):

- `mkdir build`
- `cd build`
- `cmake -G "Visual Studio 15 2017 Win64" -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DVCPKG_TARGET_TRIPLET="%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT_DIR%\scripts\buildsystems\vcpkg.cmake" ..`
- `cmake -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DVCPKG_TARGET_TRIPLET="%VCPKG_DEFAULT_TRIPLET%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT_DIR%\scripts\buildsystems\vcpkg.cmake" ..`
- ` cmake --build . --target ALL_BUILD`

If you are compiling on Windows and you are for some reasons **not** using `vcpkg` please download Eigen3 and extract it.
Within cmake-gui set the variable EIGEN3_INCLUDE_DIR to that directory.

- `mkdir build`
- `cd build`
- `cmake .. -G "Visual Studio 15 2017 Win64" -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DEIGEN3_INCLUDE_DIR="<THE_PATH_WHERE_YOU_PLACED_EIGEN3_AND_THE_EIGEN3_CMakeLists.txt>"
- `cmake .. -DG2O_BUILD_APPS=ON -DG2O_BUILD_EXAMPLES=ON -DEIGEN3_INCLUDE_DIR="<THE_PATH_WHERE_YOU_PLACED_EIGEN3_AND_THE_EIGEN3_CMakeLists.txt>"

## Cross-Compiling for Android

Expand Down
8 changes: 6 additions & 2 deletions cmake_modules/FindMETIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ if (METIS_LIBRARY_DEBUG)
set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS
DEBUG)
endif (METIS_LIBRARY_DEBUG)

find_package_handle_standard_args (METIS REQUIRED_VARS
if(WIN32)
find_package_handle_standard_args (metis REQUIRED_VARS
METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)
else(WIN32)
find_package_handle_standard_args (METIS REQUIRED_VARS
METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)
endif(WIN32)
29 changes: 29 additions & 0 deletions script/install-additional-deps-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off
set VCPKG_ROOT_DIR=%1
set VCPKG_DEFAULT_TRIPLET=%2
setlocal

rem ----------------------------------
rem Locate vcpkg using environment variables falling back to sensible defaults
rem ----------------------------------
set "VcPkgDir=%USERPROFILE%\.vcpkg\vcpkg"
set "VcPkgTriplet=x64-windows"
if defined VCPKG_ROOT_DIR if /i not "%VCPKG_ROOT_DIR%"=="" set "VcPkgDir=%VCPKG_ROOT_DIR%"
if defined VCPKG_DEFAULT_TRIPLET if /i not "%VCPKG_DEFAULT_TRIPLET%"=="" set "VcPkgTriplet=%VCPKG_DEFAULT_TRIPLET%"

pushd %VcPkgDir%

rem ==============================
rem Upgrade and Install packages.
rem ==============================
set "VcPkgLibs=cmake eigen3 suitesparse lapack-reference openblas ceres qt5 glew"

echo vcpkg found at %VcPkgDir%...
echo installing %VcPkgLibs% for triplet %VcPkgTriplet%...

call %VcPkgDir% upgrade %VcPkgLibs% --no-dry-run --triplet %VcPkgTriplet%
call %VcPkgDir% install %VcPkgLibs% --triplet %VcPkgTriplet%

popd

endlocal & set "VcPkgDir=%VcPkgDir%" & set "VcPkgTriplet=%VcPkgTriplet%"
5 changes: 3 additions & 2 deletions script/install-deps-windows.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@echo off

set VCPKG_ROOT_DIR=%1
set VCPKG_DEFAULT_TRIPLET=%2
setlocal

rem ----------------------------------
Expand All @@ -15,7 +16,7 @@ pushd %VcPkgDir%
rem ==============================
rem Upgrade and Install packages.
rem ==============================
set "VcPkgLibs=eigen3 suitesparse clapack openblas ceres"
set "VcPkgLibs=cmake eigen3 suitesparse lapack-reference openblas ceres"

echo vcpkg found at %VcPkgDir%...
echo installing %VcPkgLibs% for triplet %VcPkgTriplet%...
Expand Down

0 comments on commit dffe953

Please sign in to comment.