Skip to content

Commit e205d72

Browse files
authored
Merge pull request borglab#2182 from talregev/TalR/system_pybind
Add GTSAM_USE_SYSTEM_PYBIND option and improve cache for vcpkg
2 parents 875ba9d + 014ed49 commit e205d72

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

.github/workflows/vcpkg.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,22 @@ jobs:
2121
build_type: Release
2222
test_target: RUN_TESTS
2323
binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg\archives
24-
vcpkg_info: C:/vcpkg/installed/vcpkg/info/*
2524
python: python
2625
# check_constraint_program fail on windows. should fix it for windows.
2726
# Remove this excluded test when you fix it for windows.
2827
ctest_extra_flags: -E check_constraint_program
2928
- os: ubuntu-latest
30-
triplet: x64-linux
29+
triplet: x64-linux-release
3130
build_type: Release
3231
test_target: test
3332
binary_cache: /home/runner/.cache/vcpkg/archives
34-
vcpkg_info: /usr/local/share/vcpkg/installed/vcpkg/info/*
3533
cxxflags: -DCMAKE_CXX_FLAGS="-Wno-error=nonnull -Wno-error=maybe-uninitialized"
3634
python: python3
3735
- os: macos-latest
38-
triplet: arm64-osx
36+
triplet: arm64-osx-release
3937
build_type: Release
4038
test_target: test
4139
binary_cache: /Users/runner/.cache/vcpkg/archives
42-
vcpkg_info: /usr/local/share/vcpkg/installed/vcpkg/info/*
4340
python: python3
4441
steps:
4542
- name: Checkout
@@ -78,7 +75,7 @@ jobs:
7875
7976
- name: "Install dependencies"
8077
run: >
81-
vcpkg x-set-installed --triplet ${{ matrix.triplet }}
78+
vcpkg x-set-installed --triplet ${{ matrix.triplet }} --host-triplet ${{ matrix.triplet }}
8279
boost-assign
8380
boost-bimap
8481
boost-chrono
@@ -102,8 +99,15 @@ jobs:
10299
- name: copy files for hash
103100
shell: bash
104101
run: |
102+
VCPKG_BASH_PATH=${VCPKG_INSTALLATION_ROOT//\\//}
103+
echo $VCPKG_BASH_PATH
105104
mkdir -p vcpkg-info
106-
cp ${{ matrix.vcpkg_info }} vcpkg-info
105+
find $VCPKG_BASH_PATH/installed/ -type f -name 'vcpkg_abi_info.txt' | \
106+
while read filepath; do
107+
triplet=$(echo "$filepath" | awk -F/ '{print $(NF-3)}')
108+
port=$(echo "$filepath" | awk -F/ '{print $(NF-1)}')
109+
cp "$filepath" "vcpkg-info/${triplet}_${port}.txt"
110+
done
107111
108112
- name: Save cache dependencies
109113
uses: actions/cache/save@v4
@@ -132,15 +136,17 @@ jobs:
132136
-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake \
133137
-DVCPKG_INSTALLED_DIR=$VCPKG_INSTALLATION_ROOT/installed \
134138
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
139+
-DVCPKG_HOST_TRIPLET=${{ matrix.triplet }} \
135140
-DCMAKE_BUILD_TYPE=Release \
136141
-DGTSAM_BUILD_EXAMPLES_ALWAYS=ON \
137142
-DGTSAM_ROT3_EXPMAP=ON \
138143
-DGTSAM_POSE3_EXPMAP=ON \
139-
-DGTSAM_BUILD_PYTHON=OFF \
144+
-DGTSAM_BUILD_PYTHON=ON \
140145
-DGTSAM_BUILD_TESTS=ON \
141146
-DGTSAM_BUILD_UNSTABLE=OFF \
142147
-DGTSAM_USE_SYSTEM_EIGEN=ON \
143148
-DGTSAM_USE_SYSTEM_METIS=ON \
149+
-DGTSAM_USE_SYSTEM_PYBIND=ON \
144150
-DGTSAM_SUPPORT_NESTED_DISSECTION=ON \
145151
-DCTEST_EXTRA_ARGS="${{ matrix.ctest_extra_flags }}" \
146152
${{ matrix.cxxflags }}
@@ -150,12 +156,11 @@ jobs:
150156
run: |
151157
cmake --build build --config Release
152158
153-
# TODO Add cmake detection of external pybind.
154-
# - name: Run Python tests
155-
# shell: bash
156-
# run: |
157-
# cmake --build build --target python-install
158-
# cmake --build build --target python-test
159+
- name: Run Python tests
160+
shell: bash
161+
run: |
162+
cmake --build build --target python-install
163+
cmake --build build --target python-test
159164
160165
- name: Run tests
161166
shell: bash

python/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ if(POLICY CMP0057)
4141
cmake_policy(SET CMP0057 NEW)
4242
endif()
4343

44-
# Use bundled pybind11 version
45-
add_subdirectory(${PROJECT_SOURCE_DIR}/wrap/pybind11 pybind11)
44+
option(GTSAM_USE_SYSTEM_PYBIND "Find and use system-installed Pybind. If 'off', use the one bundled with GTSAM" OFF)
45+
46+
if(GTSAM_USE_SYSTEM_PYBIND)
47+
# try to find pybind11 on system
48+
find_package(pybind11 REQUIRED)
49+
else()
50+
# Use bundled pybind11 version
51+
add_subdirectory(${PROJECT_SOURCE_DIR}/wrap/pybind11 pybind11)
52+
endif()
4653

4754
# Set the wrapping script variable
4855
set(PYBIND_WRAP_SCRIPT "${PROJECT_SOURCE_DIR}/wrap/scripts/pybind_wrap.py")

0 commit comments

Comments
 (0)