Skip to content

Commit 298794f

Browse files
authored
Merge pull request #2232 from borglab/feature/boost_and_flags
Fix Boost and badges
2 parents ffbf47a + 9c6fcd9 commit 298794f

File tree

7 files changed

+122
-51
lines changed

7 files changed

+122
-51
lines changed

.github/scripts/python.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ function build()
4545
{
4646
export CMAKE_GENERATOR=Ninja
4747
BUILD_PYBIND="ON"
48+
49+
# Add Boost hints on Windows
50+
BOOST_CMAKE_ARGS=""
51+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then
52+
if [ -n "${BOOST_ROOT}" ]; then
53+
BOOST_ROOT_UNIX=$(echo "$BOOST_ROOT" | sed 's/\\/\//g')
54+
BOOST_CMAKE_ARGS="-DBOOST_ROOT=${BOOST_ROOT_UNIX} -DBOOST_INCLUDEDIR=${BOOST_ROOT_UNIX}/include -DBOOST_LIBRARYDIR=${BOOST_ROOT_UNIX}/lib"
55+
fi
56+
fi
57+
4858
cmake $GITHUB_WORKSPACE \
4959
-B build \
5060
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
@@ -58,9 +68,11 @@ function build()
5868
-DGTSAM_UNSTABLE_BUILD_PYTHON=${GTSAM_BUILD_UNSTABLE:-ON} \
5969
-DGTSAM_PYTHON_VERSION=$PYTHON_VERSION \
6070
-DPYTHON_EXECUTABLE:FILEPATH=$(which $PYTHON) \
71+
-DGTSAM_USE_BOOST_FEATURES=ON \
72+
-DGTSAM_ENABLE_BOOST_SERIALIZATION=ON \
6173
-DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \
62-
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/gtsam_install
63-
74+
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/gtsam_install \
75+
$BOOST_CMAKE_ARGS
6476

6577
# Set to 2 cores so that Actions does not error out during resource provisioning.
6678
cmake --build build -j2

.github/workflows/build-python.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ name: Python CI
33
# Since this is a required check, specify paths-ignore in the check-paths job
44
# instead of under 'pull_request:'. Otherwise, the check is still required but
55
# never runs, and a maintainer must bypass the check in order to merge the PR.
6-
on: [pull_request]
6+
on:
7+
push:
8+
branches:
9+
- develop
10+
paths-ignore:
11+
- '**.md'
12+
- '**.ipynb'
13+
- 'myst.yml'
14+
pull_request:
15+
paths-ignore:
16+
- '**.md'
17+
- '**.ipynb'
18+
- 'myst.yml'
719

820
# Every time you make a push to your PR, it cancel immediately the previous checks,
921
# and start a new one. The other runner will be available more quickly to your PR.

.github/workflows/build-windows.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,20 @@ jobs:
115115
- name: Configuration
116116
shell: bash
117117
run: |
118-
export CMAKE_GENERATOR=Ninja
118+
export CMAKE_GENERATOR=Ninja
119+
# Convert Windows backslashes to forward slashes for CMake
120+
BOOST_ROOT_UNIX=$(echo "$BOOST_ROOT" | sed 's/\\/\//g')
119121
cmake -E remove_directory build
120122
if [ "${{ matrix.build_type }}" = "Release" ]; then
121123
cmake -B build \
122124
-S . \
123125
-DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
124126
-DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \
125-
-DBOOST_ROOT="${BOOST_ROOT}" \
126127
-DGTSAM_USE_BOOST_FEATURES=ON \
127128
-DGTSAM_ENABLE_BOOST_SERIALIZATION=ON \
128-
-DBOOST_INCLUDEDIR="${BOOST_ROOT}\\boost\\include" \
129-
-DBOOST_LIBRARYDIR="${BOOST_ROOT}\\lib"
129+
-DBOOST_ROOT="${BOOST_ROOT_UNIX}" \
130+
-DBOOST_INCLUDEDIR="${BOOST_ROOT_UNIX}/include" \
131+
-DBOOST_LIBRARYDIR="${BOOST_ROOT_UNIX}/lib"
130132
else
131133
cmake -B build \
132134
-S . \

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ mapping (SAM) in robotics and vision, using Factor Graphs and Bayes
1313
Networks as the underlying computing paradigm rather than sparse
1414
matrices.
1515

16-
The current support matrix is:
17-
18-
| Platform | Compiler | Build Status |
19-
| :----------------: | :-------: | :------------------------------------------------------------------------------: |
20-
| Ubuntu 22.04/24.04 | gcc/clang | ![Linux CI](https://github.com/borglab/gtsam/workflows/Linux%20CI/badge.svg) |
21-
| macOS | clang | ![macOS CI](https://github.com/borglab/gtsam/workflows/macOS%20CI/badge.svg) |
22-
| Windows | MSVC | ![Windows CI](https://github.com/borglab/gtsam/workflows/Windows%20CI/badge.svg) |
2316

17+
<!-- Main CI Badges (develop branch) -->
18+
| CI Status | Platform | Compiler |
19+
|:----------|:---------|:---------|
20+
| [![Python CI](https://github.com/borglab/gtsam/actions/workflows/build-python.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/build-python.yml?query=branch%3Adevelop) | Ubuntu 22.04, MacOS 13-14, Windows | gcc/clang,MSVC |
21+
| [![vcpkg](https://github.com/borglab/gtsam/actions/workflows/vcpkg.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/vcpkg.yml?query=branch%3Adevelop) | Latest Windows/Ubuntu/Mac | - |
22+
| [![Build Wheels for Develop](https://github.com/borglab/gtsam/actions/workflows/build-cibw.yml/badge.svg?branch=develop)](https://github.com/borglab/gtsam/actions/workflows/build-cibw.yml?query=branch%3Adevelop) | See [pypi files](https://pypi.org/project/gtsam-develop/#files); no Windows| - |
2423

2524
On top of the C++ library, GTSAM includes [wrappers for MATLAB & Python](#wrappers).
2625

@@ -34,15 +33,29 @@ In the root library folder execute:
3433
mkdir build
3534
cd build
3635
cmake ..
37-
make check (optional, runs unit tests)
36+
make check # optional, runs all unit tests
3837
make install
3938
```
4039

4140
Prerequisites:
4241

43-
- [Boost](http://www.boost.org/users/download/) >= 1.65 (Ubuntu: `sudo apt-get install libboost-all-dev`)
44-
- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.0 (Ubuntu: `sudo apt-get install cmake`)
45-
- A modern compiler, i.e., at least gcc 4.7.3 on Linux.
42+
- A modern compiler:
43+
- Mac: at least xcode-14.2
44+
- Linux: at least clang-11 or gcc-9
45+
- Windows: at least msvc-14.2
46+
- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.0
47+
- Ubuntu: `sudo apt-get install cmake`
48+
49+
Optional Boost prerequisite:
50+
51+
Boost is now *optional*. Two cmake flags govern its behavior:
52+
- `GTSAM_USE_BOOST_FEATURES` = `ON|OFF`: some of our timers and concept checking in the tests still depend on boost.
53+
- `GTSAM_ENABLE_BOOST_SERIALIZATION` = `ON|OFF`: serialization of factor graphs, factors, etc still is done using boost
54+
55+
If one or both of these flags are `ON`, you need to install [Boost](http://www.boost.org/users/download/) >= 1.70
56+
- Mac: `brew install boost`
57+
- Ubuntu: `sudo apt-get install libboost-all-dev`
58+
- Windows: We highly recommend using the [vcpkg](https://github.com/microsoft/vcpkg) package manager. For other installation methods or troubleshooting, please see the guidance in the [cmake/HandleBoost.cmake](cmake/HandleBoost.cmake) script.
4659

4760
Optional prerequisites - used automatically if findable by CMake:
4861

cmake/HandleBoost.cmake

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,88 @@
1-
###############################################################################
2-
# Find boost
3-
4-
# To change the path for boost, you will need to set:
5-
# BOOST_ROOT: path to install prefix for boost
6-
# Boost_NO_SYSTEM_PATHS: set to true to keep the find script from ignoring BOOST_ROOT
1+
################################################################################
2+
# Find and configure the Boost libraries.
3+
#
4+
# To customize the Boost installation path, you can set the following variables
5+
# when running CMake:
6+
# - BOOST_ROOT: Path to the Boost installation prefix.
7+
# - BOOST_INCLUDEDIR: Path to the Boost include directory.
8+
# - BOOST_LIBRARYDIR: Path to the Boost library directory.
9+
#
10+
# These hints are particularly important for manual installations on Windows.
11+
################################################################################
712

813
if(MSVC)
9-
# By default, boost only builds static libraries on windows
10-
set(Boost_USE_STATIC_LIBS ON) # only find static libs
11-
# If we ever reset above on windows and, ...
12-
# If we use Boost shared libs, disable auto linking.
13-
# Some libraries, at least Boost Program Options, rely on this to export DLL symbols.
14+
# By default, Boost pre-compiled binaries for Windows are static libraries.
15+
set(Boost_USE_STATIC_LIBS ON)
1416
if(NOT Boost_USE_STATIC_LIBS)
1517
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_ALL_NO_LIB BOOST_ALL_DYN_LINK)
1618
endif()
17-
# Virtual memory range for PCH exceeded on VS2015
1819
if(MSVC_VERSION LESS 1910) # older than VS2017
1920
list_append_cache(GTSAM_COMPILE_OPTIONS_PRIVATE -Zm295)
2021
endif()
2122
endif()
2223

24+
# --- GUIDANCE FOR LOCAL WINDOWS DEVELOPMENT ---
25+
#
26+
# If you enable Boost features on Windows, there are two primary ways to provide
27+
# the Boost libraries:
28+
#
29+
# 1. RECOMMENDED: Use a package manager like vcpkg.
30+
# - Vcpkg (https://github.com/microsoft/vcpkg) handles the download, build,
31+
# and integration of Boost. It provides modern CMake config files and works
32+
# seamlessly with this script without any special configuration.
33+
#
34+
# 2. ALTERNATIVE: Manual Installation (e.g., pre-compiled binaries).
35+
# - If you download pre-compiled binaries, you MUST provide hints to CMake so
36+
# it can find your installation. At a minimum, set BOOST_ROOT, e.g.:
37+
# cmake .. -DBOOST_ROOT=C:/local/boost_1_87_0
38+
#
39+
################################################################################
2340

24-
# Store these in variables so they are automatically replicated in GTSAMConfig.cmake and such.
25-
set(BOOST_FIND_MINIMUM_VERSION 1.65)
26-
set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex)
41+
# Set minimum required Boost version and components.
42+
# NOTE: "system" is intentionally omitted. It is a transitive dependency of other
43+
# components (like filesystem) and will be found automatically. Explicitly
44+
# requesting it can cause issues with modern header-only versions of Boost.
45+
set(BOOST_FIND_MINIMUM_VERSION 1.70)
46+
set(BOOST_FIND_MINIMUM_COMPONENTS serialization filesystem thread program_options date_time timer chrono regex)
2747

28-
find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS} REQUIRED)
48+
# Find the Boost package. On systems with modern installations (vcpkg, Homebrew),
49+
# this will use CMake's "Config mode". With manual installations (especially on
50+
# Windows), providing the hints above will trigger the legacy "Module mode".
51+
find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} REQUIRED
52+
COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS}
53+
)
2954

30-
# Required components
31-
if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR
32-
NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY)
33-
message(FATAL_ERROR "Missing required Boost components >= v1.65, please install/upgrade Boost or configure your search paths.")
34-
endif()
55+
# Verify that the required Boost component targets were successfully found and imported.
56+
foreach(_t IN ITEMS Boost::serialization Boost::filesystem Boost::thread Boost::date_time)
57+
if(NOT TARGET ${_t})
58+
message(FATAL_ERROR "Missing required Boost component target: ${_t}. Please install/upgrade Boost or set BOOST_ROOT/Boost_DIR correctly.")
59+
endif()
60+
endforeach()
3561

3662
option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF)
37-
# Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library)
63+
3864
set(GTSAM_BOOST_LIBRARIES
3965
Boost::serialization
40-
Boost::system
4166
Boost::filesystem
4267
Boost::thread
4368
Boost::date_time
4469
Boost::regex
4570
)
46-
if (GTSAM_DISABLE_NEW_TIMERS)
47-
message("WARNING: GTSAM timing instrumentation manually disabled")
48-
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)
71+
72+
if(GTSAM_DISABLE_NEW_TIMERS)
73+
message("WARNING: GTSAM timing instrumentation manually disabled")
74+
list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS)
4975
else()
50-
if(Boost_TIMER_LIBRARY)
51-
list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono)
76+
# Link against compiled timer libraries if they exist.
77+
if(TARGET Boost::timer AND TARGET Boost::chrono)
78+
list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono)
79+
else()
80+
# Fallback for header-only timer: link librt on Linux.
81+
if(UNIX AND NOT APPLE)
82+
list(APPEND GTSAM_BOOST_LIBRARIES rt)
83+
message("WARNING: Using header-only Boost timer; adding -lrt on Linux.")
5284
else()
53-
list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt
54-
message("WARNING: GTSAM timing instrumentation will use the older, less accurate, Boost timer library because boost older than 1.48 was found.")
85+
message("WARNING: Using header-only Boost timer; no extra libs required on this platform.")
5586
endif()
56-
endif()
87+
endif()
88+
endif()

gtsam/3rdparty/GeographicLib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ set (LIBVERSION_BUILD 17.1.2)
4747
string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
4848
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
4949

50-
cmake_minimum_required (VERSION 3.5) # This version was released 2011-02-16
50+
cmake_minimum_required (VERSION 3.10)
5151

5252
# User-settable variables
5353

gtsam/3rdparty/metis/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.10)
22
project(METIS)
33

44
# Add flags for currect directory and below

0 commit comments

Comments
 (0)