Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install CentOS dependencies with vcpkg #225

Merged
merged 22 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ jobs:
$VCPKG_CACHE_DIR = "${env:COMPILER_CACHE_DIR}/vcpkg"
$VCPKG_BINARY_SOURCES = "clear;files,${VCPKG_CACHE_DIR},readwrite"
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "${env:GITHUB_ENV}"
- name: Set env (Ubuntu)
if: runner.os == 'Linux'
run: |
VCPKG_TARGET_TRIPLET="x64-linux-release"
echo "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" >> "$GITHUB_ENV"

VCPKG_INSTALLATION_ROOT="${{ github.workspace }}/vcpkg"
CMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
echo "VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" >> "$GITHUB_ENV"
echo "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" >> "$GITHUB_ENV"

# Fix: cibuildhweel cannot interpolate env variables.
CONFIG_SETTINGS="cmake.define.CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
CONFIG_SETTINGS="${CONFIG_SETTINGS} cmake.define.VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}"
echo "CIBW_CONFIG_SETTINGS_LINUX=${CONFIG_SETTINGS}" >> "$GITHUB_ENV"

# Remap caching paths to the container
CONTAINER_COMPILER_CACHE_DIR="/compiler-cache"
CIBW_CONTAINER_ENGINE="docker; create_args: -v ${COMPILER_CACHE_DIR}:${CONTAINER_COMPILER_CACHE_DIR}"
echo "CIBW_CONTAINER_ENGINE=${CIBW_CONTAINER_ENGINE}" >> "$GITHUB_ENV"
echo "COMPILER_CACHE_DIR=${CONTAINER_COMPILER_CACHE_DIR}" >> "$GITHUB_ENV"
echo "CCACHE_DIR=${CONTAINER_COMPILER_CACHE_DIR}/ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=/project" >> "$GITHUB_ENV"

# vcpkg binary caching
VCPKG_CACHE_DIR="${CONTAINER_COMPILER_CACHE_DIR}/vcpkg"
VCPKG_BINARY_SOURCES="clear;files,${VCPKG_CACHE_DIR},readwrite"
echo "VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}" >> "$GITHUB_ENV"

CIBW_ENVIRONMENT_PASS_LINUX="VCPKG_TARGET_TRIPLET VCPKG_INSTALLATION_ROOT CMAKE_TOOLCHAIN_FILE VCPKG_BINARY_SOURCES COMPILER_CACHE_DIR CCACHE_DIR CCACHE_BASEDIR"
echo "CIBW_ENVIRONMENT_PASS_LINUX=${CIBW_ENVIRONMENT_PASS_LINUX}" >> "$GITHUB_ENV"
- name: Build wheels
uses: pypa/[email protected]
env:
Expand Down
124 changes: 51 additions & 73 deletions package/install-colmap-centos.sh
Original file line number Diff line number Diff line change
@@ -1,86 +1,64 @@
#!/bin/bash
set -e -x
uname -a

CURRDIR=$(pwd)
echo "${CURRDIR}"

# ------ Install dependencies from the default repositories ------
cd ${CURRDIR}
yum install -y \
wget \
git \
gcc gcc-c++ make \
freeimage-devel \
metis-devel \
glew-devel \
suitesparse-devel \
atlas-devel \
lapack-devel \
blas-devel \
flann \
flann-devel \
lz4 \
lz4-devel
yum install -y gcc gcc-c++ ninja-build curl zip unzip tar

# ------ Install boost ------
cd ${CURRDIR}
export BOOST_FILENAME="boost-1.84.0"
wget -nv https://github.com/boostorg/boost/releases/download/${BOOST_FILENAME}/${BOOST_FILENAME}.tar.gz
tar xzf ${BOOST_FILENAME}.tar.gz
cd ${BOOST_FILENAME}
./bootstrap.sh --with-libraries=filesystem,system,program_options,graph,test --without-icu
./b2 -j$(nproc) cxxflags="-fPIC" variant=release link=shared --disable-icu install
# ccache shipped by CentOS is too old so we download and cache it.
COMPILER_TOOLS_DIR="${COMPILER_CACHE_DIR}/bin"
mkdir -p ${COMPILER_TOOLS_DIR}
if [ ! -f "${COMPILER_TOOLS_DIR}/ccache" ]; then
FILE="ccache-4.9-linux-x86_64"
curl -sSLO https://github.com/ccache/ccache/releases/download/v4.9/${FILE}.tar.xz
tar -xf ${FILE}.tar.xz
cp ${FILE}/ccache ${COMPILER_TOOLS_DIR}
fi
export PATH="${COMPILER_TOOLS_DIR}:${PATH}"
ccache --version
ccache --help

# ------ Install gflags ------
cd ${CURRDIR}
git clone --branch v2.2.2 --depth 1 https://github.com/gflags/gflags.git
cd gflags
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=ON
make -j$(nproc) install

# ------ Install glog ------
cd ${CURRDIR}
git clone --branch v0.6.0 --depth 1 https://github.com/google/glog.git
cd glog
mkdir build && cd build
cmake ..
make -j$(nproc) install

# ------ Install Eigen ------
cd ${CURRDIR}
EIGEN_VERSION="3.3.9"
export EIGEN_DIR="${CURRDIR}/eigen"
wget https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.tar.gz
tar -xvzf eigen-${EIGEN_VERSION}.tar.gz
mv eigen-${EIGEN_VERSION} ${EIGEN_DIR}
cd ${EIGEN_DIR}
mkdir build && cd build
cmake ..

# ------ Install CERES solver ------
cd ${CURRDIR}
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
git checkout $(git describe --tags) # Checkout the latest release
mkdir build && cd build
cmake .. -DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DEigen3_DIR="${EIGEN_DIR}/cmake/"
make -j$(nproc) install
git clone --branch sarlinpe/libraw-jaspter-nodefaults https://github.com/sarlinpe/vcpkg ${VCPKG_INSTALLATION_ROOT}
cd ${VCPKG_INSTALLATION_ROOT}
./bootstrap-vcpkg.sh
./vcpkg install --recurse --clean-after-build --triplet=${VCPKG_TARGET_TRIPLET} \
boost-algorithm \
boost-filesystem \
boost-graph \
boost-heap \
boost-program-options \
boost-property-map \
boost-property-tree \
boost-regex \
boost-system \
ceres[lapack,suitesparse] \
eigen3 \
flann \
jasper[core] \
freeimage \
metis \
gflags \
glog \
gtest \
sqlite3
# We force the core option of jasper to disable the unwanted opengl option.
./vcpkg integrate install

# ------ Build COLMAP ------
cd ${CURRDIR}
git clone https://github.com/colmap/colmap.git
cd colmap
git checkout ${COLMAP_COMMIT_ID}
mkdir build && cd build
CXXFLAGS="-fPIC" CFLAGS="-fPIC" cmake .. -DCMAKE_BUILD_TYPE=Release \
-DBoost_USE_STATIC_LIBS=OFF \
-DBOOST_ROOT=/usr/local \
-DCUDA_ENABLED=OFF \
-DCGAL_ENABLED=OFF \
-DGUI_ENABLED=OFF \
-DEIGEN3_INCLUDE_DIRS=$EIGEN_DIR
make -j$(nproc) install
CXXFLAGS="-fPIC" CFLAGS="-fPIC" cmake .. -GNinja \
-DCUDA_ENABLED=OFF \
-DCGAL_ENABLED=OFF \
-DGUI_ENABLED=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \
-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-ldl"
ninja install

ccache --show-stats --verbose
ccache --evict-older-than 1d
ccache --show-stats --verbose
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ test-command = "python -c \"import pycolmap; print(pycolmap.__version__)\""

[tool.cibuildwheel.linux]
before-all = "{project}/package/install-colmap-centos.sh"
config-settings = "cmake.define.EIGEN3_INCLUDE_DIRS=eigen"

[tool.cibuildwheel.macos]
before-all = "{project}/package/install-colmap-macos.sh"
Expand Down
Loading