Skip to content

Commit b8832de

Browse files
committed
Use Windows in CI
1 parent 361b382 commit b8832de

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

.github/workflows/windows-build.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Windows build
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
strategy:
14+
matrix:
15+
cpp-standard:
16+
- 17
17+
- 20
18+
# You can find specific tool versions for Windows builds in the Runner specification:
19+
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
20+
# In particular, this build uses:
21+
# cmake: 3.27.9
22+
# VSCode: 2022 Enterprise Edition (corresponding C++ version: https://blog.knatten.org/2022/08/26/microsoft-c-versions-explained/)
23+
# Ruby: 3.0.6p216
24+
# boost: 1.82.0
25+
runs-on: windows-2022
26+
env:
27+
BOOST_VERSION: 1.82.0
28+
NLOHMANN_CLONE_DIR: nlohmann
29+
NLOHMANN_TAG: v3.11.3
30+
ASIO_CLONE_DIR: asio
31+
ASIO_TAG: asio-1-29-0
32+
TCLAP_CLONE_DIR: tclap
33+
TCLAP_TAG: v1.2.5
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: install ruby tools
39+
run: |
40+
gem install bundler
41+
bundle install
42+
43+
# - name: Install Google Test
44+
# uses: MarkusJx/[email protected]
45+
46+
- name: Restore cached boost dependencies
47+
id: cache-boost-deps
48+
uses: actions/cache@v3
49+
with:
50+
path: |
51+
boost_1_82_0
52+
key: ${{ runner.os }}-boost-1820
53+
54+
- name: install boost
55+
if: steps.cache-boost-deps.outputs.cache-hit != 'true'
56+
run: |
57+
$boost_version_str = ${Env:BOOST_VERSION}.Replace(".","_")
58+
$ProgressPreference = 'SilentlyContinue'
59+
Invoke-WebRequest -Uri https://boostorg.jfrog.io/artifactory/main/release/${Env:BOOST_VERSION}/source/boost_${boost_version_str}.zip -OutFile boost_${boost_version_str}.zip
60+
7z x boost_${boost_version_str}.zip
61+
cd boost_${boost_version_str}
62+
cmd /C bootstrap
63+
./b2.exe --build-type=complete toolset=msvc --with-regex --with-program_options --with-system --with-test
64+
65+
- name: Get and build nlohmann-json
66+
run: |
67+
Start-Process "git" -ArgumentList "clone https://github.com/nlohmann/json.git $Env:NLOHMANN_CLONE_DIR --depth 1 --branch $Env:NLOHMANN_TAG" -PassThru -NoNewWindow -Wait
68+
cd $Env:NLOHMANN_CLONE_DIR
69+
cmake -B build -S .
70+
cd ..
71+
72+
- name: Get ASIO
73+
run: Start-Process "git" -ArgumentList "clone https://github.com/chriskohlhoff/asio.git $Env:ASIO_CLONE_DIR --depth 1 --branch $Env:ASIO_TAG" -PassThru -NoNewWindow -Wait
74+
75+
- name: Get TCLAP
76+
run: Start-Process "git" -ArgumentList "clone https://github.com/mirror/tclap.git $Env:TCLAP_CLONE_DIR --depth 1 --branch $Env:TCLAP_TAG" -PassThru -NoNewWindow -Wait
77+
78+
- name: build and run
79+
run: |
80+
$current_script_dir = Get-Location | Select-Object -Expand "Path"
81+
$Env:nlohmann_json_DIR = "${current_script_dir}/$Env:NLOHMANN_CLONE_DIR/build"
82+
$Env:Asio_ROOT = "${current_script_dir}/$Env:ASIO_CLONE_DIR/asio"
83+
$Env:TCLAP_ROOT = "${current_script_dir}/$Env:TCLAP_CLONE_DIR"
84+
$Env:cpp_standard = ${{ matrix.cpp-standard }}
85+
./run-windows.ps1

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
# Qt Creator
2121
/CMakeLists.txt.user
2222

23+
# build folder
24+
build

run-windows.ps1

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# --- Function definitions ---
2+
function Invoke-CMake {
3+
param (
4+
$Arguments
5+
)
6+
$process = Start-Process "cmake" -ArgumentList "$Arguments" -NoNewWindow -Wait -PassThru
7+
If ($process.ExitCode -ne 0) {
8+
Write-Host "Abort script execution due to CMake error."
9+
Exit(42)
10+
}
11+
}
12+
13+
function Get-VariableOrEnv {
14+
param (
15+
[string]$Name
16+
)
17+
18+
$envValue = [Environment]::GetEnvironmentVariable($Name)
19+
if ($envValue -ne $null) {
20+
return $envValue
21+
}
22+
23+
if (Get-Variable -Name $Name -ErrorAction SilentlyContinue) {
24+
return (Get-Variable -Name $Name).Value
25+
}
26+
27+
return $null
28+
}
29+
30+
# --- Variable definitions ---
31+
$cpp_standard = Get-VariableOrEnv -Name "cpp_standard"
32+
33+
$nlohmann_json_DIR = Get-VariableOrEnv -Name "nlohmann_json_DIR"
34+
$Asio_ROOT = Get-VariableOrEnv -Name "Asio_ROOT"
35+
$TCLAP_ROOT = Get-VariableOrEnv -Name "TCLAP_ROOT"
36+
$Env:BOOST_ROOT = "boost_${Env:BOOST_VERSION}".Replace(".","_")
37+
38+
$Env:CTEST_OUTPUT_ON_FAILURE="ON"
39+
40+
41+
# --- Script ---
42+
43+
Invoke-CMake "-E","make_directory","build"
44+
45+
$cmake_params = "-E chdir build cmake",
46+
"-DBUILD_SHARED_LIBS=`"${BUILD_SHARED_LIBS}`"",
47+
"-DCMAKE_INSTALL_PREFIX=${HOME}/.local"
48+
49+
$cmake_params += "-DCMAKE_CXX_STANDARD=${cpp_standard}"
50+
51+
$cmake_params += "-DCUKE_ENABLE_BOOST_TEST=OFF"
52+
$cmake_params += "-DCUKE_ENABLE_GTEST=OFF"
53+
$cmake_params += "-DCUKE_ENABLE_QT_6=OFF"
54+
$cmake_params += "-DCUKE_ENABLE_EXAMPLES=OFF"
55+
$cmake_params += "-DCUKE_TESTS_UNIT=OFF"
56+
$cmake_params += "-DCUKE_CODE_COVERAGE=OFF"
57+
58+
$cmake_params += "-Dnlohmann_json_DIR=${nlohmann_json_DIR}"
59+
$cmake_params += "-DAsio_ROOT=${Asio_ROOT}"
60+
$cmake_params += "-DTCLAP_ROOT=${TCLAP_ROOT}"
61+
62+
$cmake_params += ".."
63+
64+
65+
Invoke-CMake "$cmake_params"
66+
Invoke-CMake "--build","build" #,"--parallel"

src/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,14 @@ foreach(TARGET
105105
PUBLIC
106106
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
107107
$<BUILD_INTERFACE:${CUKE_INCLUDE_DIR}>
108+
$<BUILD_INTERFACE:${ASIO_INCLUDE_DIR}>
109+
$<BUILD_INTERFACE:${TCLAP_INCLUDE_DIR}>
108110
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
109111
)
110112
target_link_libraries(${TARGET}
111113
PRIVATE
112114
${CUKE_EXTRA_PRIVATE_LIBRARIES}
115+
nlohmann_json::nlohmann_json
113116
)
114117
# Don't export or import symbols for statically linked libraries
115118
get_property(type TARGET ${TARGET} PROPERTY TYPE)

0 commit comments

Comments
 (0)