Skip to content

Commit 1dcbfb8

Browse files
committed
Add vcpkg ci
1 parent 6c6db8a commit 1dcbfb8

File tree

4 files changed

+175
-10
lines changed

4 files changed

+175
-10
lines changed

.github/workflows/build-special.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ jobs:
180180
run: |
181181
sudo apt-get install libeigen3-dev
182182
echo "GTSAM_USE_SYSTEM_EIGEN=ON" >> $GITHUB_ENV
183-
# TODO(dellaert): This does not work yet?
184-
# sudo apt-get install metis
185-
# echo "GTSAM_USE_SYSTEM_METIS=ON" >> $GITHUB_ENV
183+
sudo apt-get install libmetis-dev
184+
echo "GTSAM_USE_SYSTEM_METIS=ON" >> $GITHUB_ENV
186185
187186
- name: Turn off boost
188187
if: matrix.flag == 'no_boost'

.github/workflows/vcpkg.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: vcpkg
2+
on:
3+
pull_request:
4+
5+
# Every time you make a push to your PR, it cancel immediately the previous checks,
6+
# and start a new one. The other runner will be available more quickly to your PR.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build:
13+
name: ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: windows-latest
20+
triplet: x64-windows-release
21+
build_type: Release
22+
test_target: RUN_TESTS
23+
binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg\archives
24+
vcpkg_info: C:/vcpkg/installed/vcpkg/info/*
25+
python: python
26+
- os: ubuntu-latest
27+
triplet: x64-linux
28+
build_type: Release
29+
test_target: test
30+
binary_cache: /home/runner/.cache/vcpkg/archives
31+
vcpkg_info: /usr/local/share/vcpkg/installed/vcpkg/info/*
32+
cxxflags: -DCMAKE_CXX_FLAGS="-Wno-error=nonnull -Wno-error=maybe-uninitialized"
33+
python: python3
34+
- os: macos-latest
35+
triplet: arm64-osx
36+
build_type: Release
37+
test_target: test
38+
binary_cache: /Users/runner/.cache/vcpkg/archives
39+
vcpkg_info: /usr/local/share/vcpkg/installed/vcpkg/info/*
40+
python: python3
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Restore cache dependencies
46+
uses: actions/cache/restore@v3
47+
with:
48+
path: ${{ matrix.binary_cache }}
49+
key: ${{ matrix.os }}
50+
restore-keys: ${{ matrix.os }}
51+
52+
- name: Setup msbuild
53+
if: runner.os == 'Windows'
54+
uses: ilammy/msvc-dev-cmd@v1
55+
with:
56+
arch: x64
57+
toolset: 14.40
58+
59+
- name: cl version
60+
if: runner.os == 'Windows'
61+
shell: cmd
62+
run: cl
63+
64+
- name: Install vcpkg python dependencies
65+
if: runner.os == 'Linux'
66+
shell: bash
67+
run: |
68+
sudo apt-get install autoconf automake autoconf-archive
69+
70+
- name: Install vcpkg python dependencies
71+
if: runner.os == 'macOS'
72+
shell: bash
73+
run: |
74+
brew install autoconf automake autoconf-archive
75+
76+
- name: "Install dependencies"
77+
run: >
78+
vcpkg x-set-installed --triplet ${{ matrix.triplet }}
79+
boost-assign
80+
boost-bimap
81+
boost-chrono
82+
boost-date-time
83+
boost-filesystem
84+
boost-format
85+
boost-graph
86+
boost-math
87+
boost-program-options
88+
boost-regex
89+
boost-serialization
90+
boost-system
91+
boost-thread
92+
boost-timer
93+
eigen3
94+
metis
95+
tbb
96+
pybind11
97+
geographiclib
98+
99+
- name: copy files for hash
100+
shell: bash
101+
run: |
102+
mkdir -p vcpkg-info
103+
cp ${{ matrix.vcpkg_info }} vcpkg-info
104+
105+
- name: Save cache dependencies
106+
uses: actions/cache/save@v4
107+
with:
108+
path: ${{ matrix.binary_cache }}
109+
key: ${{ matrix.os }}-${{ hashFiles('vcpkg-info/*') }}
110+
111+
- name: Install python packages
112+
shell: bash
113+
run: |
114+
$VCPKG_INSTALLATION_ROOT/installed/${{ matrix.triplet }}/tools/python3/${{ matrix.python }} -m ensurepip --upgrade
115+
$VCPKG_INSTALLATION_ROOT/installed/${{ matrix.triplet }}/tools/python3/${{ matrix.python }} -m pip install -r python/dev_requirements.txt
116+
117+
- name: cmake config
118+
if: success()
119+
shell: bash
120+
run: |
121+
export CL=-openmp:experimental
122+
123+
# This is due an error in linux:
124+
# error: argument 2 null where non-null expected [-Werror=nonnull]
125+
# return __builtin_memcmp(__first1, __first2, sizeof(_Tp) * __num);
126+
# Remove `${{ matrix.cxxflags }}` when the compilation error solved
127+
128+
cmake . -B build -G Ninja \
129+
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake \
130+
-DVCPKG_INSTALLED_DIR=$VCPKG_INSTALLATION_ROOT/installed \
131+
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
132+
-DCMAKE_BUILD_TYPE=Release \
133+
-DGTSAM_BUILD_EXAMPLES_ALWAYS=ON \
134+
-DGTSAM_ROT3_EXPMAP=ON \
135+
-DGTSAM_POSE3_EXPMAP=ON \
136+
-DGTSAM_BUILD_PYTHON=ON \
137+
-DGTSAM_BUILD_TESTS=ON \
138+
-DGTSAM_BUILD_UNSTABLE=OFF \
139+
-DGTSAM_USE_SYSTEM_EIGEN=ON \
140+
-DGTSAM_USE_SYSTEM_METIS=ON \
141+
-DGTSAM_SUPPORT_NESTED_DISSECTION=ON \
142+
${{ matrix.cxxflags }}
143+
144+
- name: cmake build
145+
shell: bash
146+
run: |
147+
cmake --build build --config Release
148+
149+
- name: Run Python tests
150+
shell: bash
151+
run: |
152+
cmake --build build --target python-install
153+
cmake --build build --target python-test
154+
155+
- name: Run tests
156+
shell: bash
157+
run: |
158+
cmake --build build --target check

cmake/HandleMetis.cmake

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,26 @@ option(GTSAM_USE_SYSTEM_METIS "Find and use system-installed libmetis. If 'off',
1212

1313
if(GTSAM_USE_SYSTEM_METIS)
1414
# Debian package: libmetis-dev
15+
find_package(METIS CONFIG NAMES metis)
16+
if(NOT METIS_FOUND)
17+
find_path(METIS_INCLUDE_DIR metis.h REQUIRED)
18+
find_library(METIS_LIBRARY metis REQUIRED)
19+
if(METIS_INCLUDE_DIR AND METIS_LIBRARY)
20+
set(METIS_FOUND ON)
21+
endif()
22+
endif()
1523

16-
find_path(METIS_INCLUDE_DIR metis.h REQUIRED)
17-
find_library(METIS_LIBRARY metis REQUIRED)
18-
19-
if(METIS_INCLUDE_DIR AND METIS_LIBRARY)
24+
if(METIS_FOUND)
2025
mark_as_advanced(METIS_INCLUDE_DIR)
2126
mark_as_advanced(METIS_LIBRARY)
22-
2327
add_library(metis-gtsam-if INTERFACE)
2428
target_include_directories(metis-gtsam-if BEFORE INTERFACE ${METIS_INCLUDE_DIR}
2529
# gtsam_unstable/partition/FindSeparator-inl.h uses internal metislib.h API
2630
# via extern "C"
2731
$<BUILD_INTERFACE:${GTSAM_SOURCE_DIR}/gtsam/3rdparty/metis/libmetis>
2832
$<BUILD_INTERFACE:${GTSAM_SOURCE_DIR}/gtsam/3rdparty/metis/GKlib>
2933
)
30-
target_link_libraries(metis-gtsam-if INTERFACE ${METIS_LIBRARY})
34+
target_link_libraries(metis-gtsam-if INTERFACE ${METIS_LIBRARY} metis)
3135
endif()
3236
else()
3337
# Bundled version:

wrap/pybind11/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
100100
else()
101101
set(PYBIND11_MASTER_PROJECT OFF)
102102
set(pybind11_system SYSTEM)
103-
set(_pybind11_findpython_default OFF)
103+
if(CMAKE_VERSION VERSION_LESS "3.18")
104+
set(_pybind11_findpython_default OFF)
105+
else()
106+
set(_pybind11_findpython_default ON)
107+
endif()
104108
endif()
105109

106110
# Options

0 commit comments

Comments
 (0)