Skip to content

Commit c0579ef

Browse files
ahojnneslpanaf
andauthored
Add CI build for Windows (#46)
* Update README.md * update CI pipelines * add install-ccache.ps1 * d * d * directly find suitesparse (before assume Ceres achieve this) * try removing the direct linking of CHOLMOD library * add vcpkg.json * remove unnecessary features * d * remove requirement for cuda * d * d * d * d * D * d * d * d * d * d * d * d * d * d * d * d * d * d * d * d * d * d * d --------- Co-authored-by: Linfei Pan <36349740+lpanaf@users.noreply.github.com> Co-authored-by: lpanaf <linpan@student.ethz.ch>
1 parent 1dc20d7 commit c0579ef

File tree

11 files changed

+1045
-31
lines changed

11 files changed

+1045
-31
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter(Mandatory = $true)]
4+
[string] $Destination
5+
)
6+
7+
$version = "4.8"
8+
$folder = "ccache-$version-windows-x86_64"
9+
$url = "https://github.com/ccache/ccache/releases/download/v$version/$folder.zip"
10+
$expectedSha256 = "A2B3BAB4BB8318FFC5B3E4074DC25636258BC7E4B51261F7D9BEF8127FDA8309"
11+
12+
$ErrorActionPreference = "Stop"
13+
14+
try {
15+
New-Item -Path "$Destination" -ItemType Container -ErrorAction SilentlyContinue
16+
17+
Write-Host "Download CCache"
18+
$zipFilePath = Join-Path "$env:TEMP" "$folder.zip"
19+
Invoke-WebRequest -Uri $url -UseBasicParsing -OutFile "$zipFilePath" -MaximumRetryCount 3
20+
21+
$hash = Get-FileHash $zipFilePath -Algorithm "sha256"
22+
if ($hash.Hash -ne $expectedSha256) {
23+
throw "File $Path hash $hash.Hash did not match expected hash $expectedHash"
24+
}
25+
26+
Write-Host "Unzip CCache"
27+
Expand-Archive -Path "$zipFilePath" -DestinationPath "$env:TEMP"
28+
29+
Write-Host "Move CCache"
30+
Move-Item -Force "$env:TEMP/$folder/ccache.exe" "$Destination"
31+
Remove-Item "$zipFilePath"
32+
Remove-Item -Recurse "$env:TEMP/$folder"
33+
}
34+
catch {
35+
Write-Host "Installation failed with an error"
36+
$_.Exception | Format-List
37+
exit -1
38+
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ jobs:
162162
-DCMAKE_BUILD_TYPE=${{ matrix.config.cmakeBuildType }} \
163163
-DCMAKE_INSTALL_PREFIX=./install \
164164
-DCMAKE_CUDA_ARCHITECTURES=50 \
165-
-DSuiteSparse_CHOLMOD_LIBRARY="/usr/lib/x86_64-linux-gnu/libcholmod.so" \
166-
-DSuiteSparse_CHOLMOD_INCLUDE_DIR="/usr/include/suitesparse" \
167165
-DTESTS_ENABLED=ON \
168166
-DASAN_ENABLED=${{ matrix.config.asanEnabled }}
169167
ninja -k 10000

.github/workflows/windows.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [ assigned, opened, synchronize, reopened ]
9+
release:
10+
types: [ published, edited ]
11+
12+
jobs:
13+
build:
14+
name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }}
15+
runs-on: ${{ matrix.config.os }}
16+
strategy:
17+
matrix:
18+
config: [
19+
{
20+
os: windows-2019,
21+
cmakeBuildType: Release,
22+
cudaEnabled: false,
23+
testsEnabled: true,
24+
exportPackage: false,
25+
},
26+
{
27+
os: windows-2022,
28+
cmakeBuildType: Release,
29+
cudaEnabled: false,
30+
testsEnabled: true,
31+
exportPackage: true,
32+
},
33+
]
34+
35+
env:
36+
COMPILER_CACHE_VERSION: 1
37+
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache
38+
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache
39+
CCACHE_BASEDIR: ${{ github.workspace }}
40+
VCPKG_COMMIT_ID: e01906b2ba7e645a76ee021a19de616edc98d29f
41+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Export GitHub Actions cache env
47+
uses: actions/github-script@v7
48+
with:
49+
script: |
50+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
51+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
52+
53+
- name: Compiler cache
54+
uses: actions/cache@v4
55+
id: cache-builds
56+
with:
57+
key: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}-${{ github.run_id }}-${{ github.run_number }}
58+
restore-keys: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}
59+
path: ${{ env.COMPILER_CACHE_DIR }}
60+
61+
- name: Install ccache
62+
shell: pwsh
63+
run: |
64+
New-Item -ItemType Directory -Force -Path "${{ env.CCACHE_DIR }}"
65+
echo "${{ env.COMPILER_CACHE_DIR }}/bin" | Out-File -Encoding utf8 -Append -FilePath $env:GITHUB_PATH
66+
67+
if (Test-Path -PathType Leaf "${{ env.COMPILER_CACHE_DIR }}/bin/ccache.exe") {
68+
exit
69+
}
70+
71+
.github/workflows/install-ccache.ps1 -Destination "${{ env.COMPILER_CACHE_DIR }}/bin"
72+
73+
- name: Install CMake and Ninja
74+
uses: lukka/get-cmake@latest
75+
76+
- name: Setup vcpkg
77+
shell: pwsh
78+
run: |
79+
./scripts/shell/enter_vs_dev_shell.ps1
80+
cd ${{ github.workspace }}
81+
git clone https://github.com/microsoft/vcpkg
82+
cd vcpkg
83+
git reset --hard ${{ env.VCPKG_COMMIT_ID }}
84+
./bootstrap-vcpkg.bat
85+
86+
- name: Configure and build
87+
shell: pwsh
88+
run: |
89+
./scripts/shell/enter_vs_dev_shell.ps1
90+
cd ${{ github.workspace }}
91+
./vcpkg/vcpkg.exe integrate install
92+
mkdir build
93+
cd build
94+
cmake .. `
95+
-GNinja `
96+
-DCMAKE_MAKE_PROGRAM=ninja `
97+
-DCMAKE_BUILD_TYPE=Release `
98+
-DTESTS_ENABLED=ON `
99+
-DCUDA_ENABLED=OFF `
100+
-DGUI_ENABLED=OFF `
101+
-DCGAL_ENABLED=OFF `
102+
-DCMAKE_CUDA_ARCHITECTURES=all-major `
103+
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" `
104+
-DVCPKG_TARGET_TRIPLET=x64-windows-release `
105+
-DCMAKE_INSTALL_PREFIX=install
106+
ninja
107+
108+
- name: Run tests
109+
shell: pwsh
110+
run: |
111+
./vcpkg/vcpkg.exe integrate install
112+
cd build
113+
ctest -E .+colmap_.* --output-on-failure
114+
115+
- name: Export package
116+
if: matrix.config.exportPackage
117+
shell: pwsh
118+
run: |
119+
./vcpkg/vcpkg.exe integrate install
120+
121+
cd build
122+
ninja install
123+
124+
../vcpkg/vcpkg.exe install `
125+
--triplet=x64-windows-release
126+
../vcpkg/vcpkg.exe export --raw --output-dir vcpkg_export --output glomap
127+
cp vcpkg_export/glomap/installed/x64-windows/bin/*.dll install/bin
128+
cp vcpkg_export/glomap/installed/x64-windows-release/bin/*.dll install/bin
129+
130+
- name: Upload package
131+
uses: actions/upload-artifact@v4
132+
if: ${{ matrix.config.exportPackage }}
133+
with:
134+
name: glomap-x64-windows
135+
path: build/install
136+
137+
- name: Cleanup compiler cache
138+
shell: pwsh
139+
run: |
140+
ccache --show-stats --verbose
141+
ccache --evict-older-than 1d
142+
ccache --show-stats --verbose

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ option(FETCH_POSELIB "Whether to use PoseLib with FetchContent or with self-inst
1616

1717
include(cmake/FindDependencies.cmake)
1818

19+
# Propagate options to vcpkg manifest.
1920
if (TESTS_ENABLED)
2021
enable_testing()
2122
endif()

cmake/FindDependencies.cmake

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
2+
3+
find_package(Eigen3 3.4 REQUIRED)
4+
find_package(SuiteSparse COMPONENTS CHOLMOD REQUIRED)
5+
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
6+
find_package(Boost REQUIRED)
7+
8+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
9+
find_package(Glog REQUIRED)
10+
if(DEFINED glog_VERSION_MAJOR)
11+
# Older versions of glog don't export version variables.
12+
add_definitions("-DGLOG_VERSION_MAJOR=${glog_VERSION_MAJOR}")
13+
add_definitions("-DGLOG_VERSION_MINOR=${glog_VERSION_MINOR}")
14+
endif()
15+
endif()
16+
17+
if(TESTS_ENABLED)
18+
message(STATUS "Enabling tests")
19+
find_package(GTest REQUIRED)
20+
endif()
21+
22+
if (OPENMP_ENABLED)
23+
message(STATUS "Enabling OpenMP")
24+
find_package(OpenMP REQUIRED)
25+
endif()
26+
127
include(FetchContent)
228
FetchContent_Declare(PoseLib
329
GIT_REPOSITORY https://github.com/PoseLib/PoseLib.git
@@ -25,25 +51,3 @@ else()
2551
find_package(COLMAP REQUIRED)
2652
endif()
2753
message(STATUS "Configuring COLMAP... done")
28-
29-
find_package(Eigen3 3.4 REQUIRED)
30-
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
31-
find_package(Boost REQUIRED)
32-
33-
if(TESTS_ENABLED)
34-
message(STATUS "Enabling tests")
35-
find_package(GTest REQUIRED)
36-
endif()
37-
38-
if (OPENMP_ENABLED)
39-
message(STATUS "Enabling OpenMP")
40-
find_package(OpenMP REQUIRED)
41-
endif()
42-
43-
find_package(SuiteSparse QUIET)
44-
if(SuiteSparse_FOUND)
45-
set(SuiteSparse_CHOLMOD_INCLUDE_DIR "${SUITESPARSE_INCLUDE_DIRS}/suitesparse")
46-
set(SuiteSparse_CHOLMOD_LIBRARY SuiteSparse::cholmod)
47-
else()
48-
message(STATUS "SuiteSparse not found, assuming Ceres provides SuiteSparse")
49-
endif()

cmake/FindGlog.cmake

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright (c) 2023, ETH Zurich and UNC Chapel Hill.
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
#
10+
# * Redistributions in binary form must reproduce the above copyright
11+
# notice, this list of conditions and the following disclaimer in the
12+
# documentation and/or other materials provided with the distribution.
13+
#
14+
# * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of
15+
# its contributors may be used to endorse or promote products derived
16+
# from this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
# POSSIBILITY OF SUCH DAMAGE.
29+
30+
31+
# Find package module for Glog library.
32+
#
33+
# The following variables are set by this module:
34+
#
35+
# GLOG_FOUND: TRUE if Glog is found.
36+
# glog::glog: Imported target to link against.
37+
#
38+
# The following variables control the behavior of this module:
39+
#
40+
# GLOG_INCLUDE_DIR_HINTS: List of additional directories in which to
41+
# search for Glog includes.
42+
# GLOG_LIBRARY_DIR_HINTS: List of additional directories in which to
43+
# search for Glog libraries.
44+
45+
set(GLOG_INCLUDE_DIR_HINTS "" CACHE PATH "Glog include directory")
46+
set(GLOG_LIBRARY_DIR_HINTS "" CACHE PATH "Glog library directory")
47+
48+
unset(GLOG_FOUND)
49+
50+
find_package(glog CONFIG QUIET)
51+
if(TARGET glog::glog)
52+
set(GLOG_FOUND TRUE)
53+
message(STATUS "Found Glog")
54+
message(STATUS " Target : glog::glog")
55+
else()
56+
# Older versions of glog don't come with a find_package config.
57+
# Fall back to custom logic to find the library and remap to imported target.
58+
59+
include(FindPackageHandleStandardArgs)
60+
61+
list(APPEND GLOG_CHECK_INCLUDE_DIRS
62+
/usr/local/include
63+
/usr/local/homebrew/include
64+
/opt/local/var/macports/software
65+
/opt/local/include
66+
/usr/include)
67+
list(APPEND GLOG_CHECK_PATH_SUFFIXES
68+
glog/include
69+
glog/Include
70+
Glog/include
71+
Glog/Include
72+
src/windows)
73+
74+
list(APPEND GLOG_CHECK_LIBRARY_DIRS
75+
/usr/local/lib
76+
/usr/local/homebrew/lib
77+
/opt/local/lib
78+
/usr/lib)
79+
list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
80+
glog/lib
81+
glog/Lib
82+
Glog/lib
83+
Glog/Lib
84+
x64/Release)
85+
86+
find_path(GLOG_INCLUDE_DIRS
87+
NAMES
88+
glog/logging.h
89+
PATHS
90+
${GLOG_INCLUDE_DIR_HINTS}
91+
${GLOG_CHECK_INCLUDE_DIRS}
92+
PATH_SUFFIXES
93+
${GLOG_CHECK_PATH_SUFFIXES})
94+
find_library(GLOG_LIBRARIES
95+
NAMES
96+
glog
97+
libglog
98+
PATHS
99+
${GLOG_LIBRARY_DIR_HINTS}
100+
${GLOG_CHECK_LIBRARY_DIRS}
101+
PATH_SUFFIXES
102+
${GLOG_CHECK_LIBRARY_SUFFIXES})
103+
104+
if(GLOG_INCLUDE_DIRS AND GLOG_LIBRARIES)
105+
set(GLOG_FOUND TRUE)
106+
message(STATUS "Found Glog")
107+
message(STATUS " Includes : ${GLOG_INCLUDE_DIRS}")
108+
message(STATUS " Libraries : ${GLOG_LIBRARIES}")
109+
endif()
110+
111+
add_library(glog::glog INTERFACE IMPORTED)
112+
target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
113+
target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARIES})
114+
endif()
115+
116+
if(NOT GLOG_FOUND AND GLOG_FIND_REQUIRED)
117+
message(FATAL_ERROR "Could not find Glog")
118+
endif()

0 commit comments

Comments
 (0)