Skip to content

Commit 5e910e2

Browse files
Adding windows support through conan
1 parent 5a8d2fd commit 5e910e2

File tree

6 files changed

+147
-94
lines changed

6 files changed

+147
-94
lines changed

.github/workflows/cd.yml

Lines changed: 73 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,44 @@ jobs:
4545
strategy:
4646
fail-fast: false
4747
matrix:
48-
# platform: [macos-13, windows-latest, ubuntu-latest, macos-14]
49-
platform: [macos-13, ubuntu-latest, macos-14]
48+
platform: [macos-13, windows-latest, ubuntu-latest, macos-14]
5049

5150
runs-on: ${{ matrix.platform }}
5251

5352
steps:
54-
- name: checkout vcell-solvers repo
53+
- name: checkout vcell-ode repo
5554
uses: actions/checkout@v4
5655

57-
- uses: actions/setup-python@v5
56+
- name: Install Python 3.10
57+
uses: actions/setup-python@v5
5858
with:
5959
python-version: '3.10'
6060

61+
- name: Install Windows Dependencies (Part 0 - Setup LLVM-style)
62+
if: matrix.platform == 'windows-latest'
63+
uses: llvm/actions/setup-windows@main
64+
with:
65+
arch: amd64
66+
67+
- name: Install Windows Dependencies (Part 1 - Configure Conan)
68+
if: matrix.platform == 'windows-latest'
69+
shell: powershell
70+
run: |
71+
choco install conan -y
72+
$conanDir = "C:\Program Files\Conan\conan"
73+
$env:PATH = "$conanDir;$env:PATH"
74+
$conanDir | Set-Content -Path $env:GITHUB_PATH
75+
$env:CONAN_HOME = "C:\.conan"
76+
"CONAN_HOME=C:\.conan" | Out-File -FilePath $env:GITHUB_ENV -Append
77+
conan --version
78+
conan profile detect --force
79+
80+
- name: Install Windows Dependencies (Part 2 - Reconfigure Conan)
81+
if: matrix.platform == 'windows-latest'
82+
shell: bash
83+
run: |
84+
cp conan-profiles/CI-CD/Windows-AMD64_profile.txt $CONAN_HOME/profiles/default
85+
6186
- name: Install Intel MacOS dependencies
6287
if: matrix.platform == 'macos-13'
6388
shell: bash
@@ -92,30 +117,42 @@ jobs:
92117
touch ~/.conan2/profiles/default # if we don't make a file first, cp thinks its a folder that doesn't exist
93118
cp conan-profiles/CI-CD/Linux-AMD64_profile.txt ~/.conan2/profiles/default
94119
120+
- name: Install Dependencies through Conan on Windows
121+
if: matrix.platform == 'windows-latest'
122+
shell: powershell
123+
run: |
124+
conan install . --output-folder build --build=missing -o include_messaging=False
125+
95126
- name: Install Dependencies through Conan on Unix
127+
if: matrix.platform != 'windows-latest'
96128
shell: bash
97129
run: |
98-
conan install . --output-folder build --build SundialsSolverStandalone_x64
130+
conan install . --output-folder build --build=missing
99131
100-
# - name: Build on Macos
101-
# if: matrix.platform == 'macos-13' || matrix.platform == 'macos-14'
102-
# run: |
103-
# platform=macos
104-
# echo "working dir is $PWD"
105-
#
106-
# cd build
107-
# export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
108-
# cmake -B . -S .. -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Debug
109-
# cmake --build .
132+
- name: Build Windows
133+
if: matrix.platform == 'windows-latest'
134+
shell: powershell
135+
run: |
136+
cd build
137+
./conanbuild.ps1
138+
conan build .. -pr ../conan-profiles/CI-CD/Windows-AMD64_profile.txt
110139
111140
- name: Build Unix
112141
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-13' || matrix.platform == 'macos-14'
113142
run: |
114143
echo "working dir is $PWD"
115144
116145
cd build
146+
source conanbuild.sh
117147
cmake -B . -S .. -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Debug
118-
cmake --build .
148+
cmake --build . --config Release
149+
150+
- name: Test Windows
151+
if: matrix.platform == 'windows-latest'
152+
run: |
153+
cd build
154+
ctest -VV
155+
./bin/SundialsSolverStandalone_x64 || true
119156
120157
- name: Test Unix
121158
if: matrix.platform == 'macos-13' || matrix.platform == 'macos-14' || matrix.platform == 'ubuntu-latest'
@@ -127,36 +164,6 @@ jobs:
127164
echo "------ running SundialsSolverStandalone_x64 ------"
128165
./bin/SundialsSolverStandalone_x64 || true
129166
130-
# - name: Setup tmate session
131-
# uses: mxschmitt/action-tmate@v3
132-
# with:
133-
# limit-access-to-actor: false
134-
135-
136-
# - name: Install Windows Dependencies
137-
# if: matrix.platform == 'windows-latest'
138-
# uses: msys2/setup-msys2@v2
139-
# with:
140-
# msystem: CLANG64
141-
# update: true
142-
# install: >
143-
# zip
144-
# git
145-
# mingw-w64-clang-x86_64-curl
146-
# mingw-w64-clang-x86_64-toolchain
147-
# mingw-w64-clang-x86_64-flang
148-
# mingw-w64-clang-x86_64-cmake
149-
# mingw-w64-clang-x86_64-boost
150-
# mingw-w64-clang-x86_64-hdf5
151-
# mingw-w64-clang-x86_64-libzip
152-
# mingw-w64-clang-x86_64-netcdf
153-
# mingw-w64-clang-x86_64-zlib
154-
# mingw-w64-clang-x86_64-libaec
155-
156-
# - name: Setup tmate session
157-
# uses: mxschmitt/action-tmate@v3
158-
# with:
159-
# limit-access-to-actor: false
160167
161168
# - name: Build Windows
162169
# if: matrix.platform == 'windows-latest'
@@ -180,23 +187,6 @@ jobs:
180187
#
181188
# ninja -j 1
182189

183-
# - name: Test Windows
184-
# if: matrix.platform == 'windows-latest'
185-
# shell: msys2 {0}
186-
# run: |
187-
# platform=windows
188-
# echo "working dir is $PWD"
189-
#
190-
# cd build
191-
#
192-
# export PATH="/d/a/_temp/msys64/clang64/bin:$PATH"
193-
# pacman -Sy --noconfirm diffutils
194-
#
195-
# ctest -VV
196-
#
197-
# echo "------ running SundialsSolverStandalone_x64 ------"
198-
# ./bin/SundialsSolverStandalone_x64 || true
199-
200190

201191
- name: fix Macos shared object paths
202192
if: matrix.platform == 'macos-13' || matrix.platform == 'macos-14'
@@ -213,20 +203,20 @@ jobs:
213203
../../.github/scripts/install_name_tool_macos.sh
214204
tar czvf ../upload/mac64.tgz --dereference .
215205
216-
# - name: handle shared object paths for Windows native build
217-
# if: matrix.platform == 'windows-latest'
218-
# shell: msys2 {0}
219-
# run: |
220-
# mkdir build/upload
221-
# cd build/bin
222-
# rm hello_test TestVCellStoch testzip ziptool || true
223-
# ls *.exe | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
224-
# ls *.dll | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
225-
# ls *.dll | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
226-
# chmod u+w,+x *
227-
# zip ../upload/win64.zip ./*
228-
# cd ../..
229-
# # fi
206+
- name: handle shared object paths for Windows native build
207+
if: matrix.platform == 'windows-latest'
208+
shell: bash
209+
run: |
210+
mkdir build/upload
211+
cd build/bin
212+
rm hello_test TestVCellStoch testzip ziptool || true
213+
ls *.exe | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
214+
ls *.dll | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
215+
ls *.dll | awk '{print $1}' | xargs -I '{}' ldd '{}' | grep '=> /' | grep -v build | grep -iv windows | awk '{print $3}' | xargs -I '{}' cp -vn '{}' . || true
216+
chmod u+w,+x *
217+
zip ../upload/win64.zip ./*
218+
cd ../..
219+
# fi
230220
231221
- name: handle shared object paths for Linux native build
232222
if: matrix.platform == 'ubuntu-latest'
@@ -256,12 +246,12 @@ jobs:
256246
name: macos_arm64.tgz
257247
path: build/upload/mac64.tgz
258248

259-
# - name: Upload Windows binaries
260-
# if: matrix.platform == 'windows-latest'
261-
# uses: actions/upload-artifact@v4
262-
# with:
263-
# name: win64.zip
264-
# path: build/upload/win64.zip
249+
- name: Upload Windows binaries
250+
if: matrix.platform == 'windows-latest'
251+
uses: actions/upload-artifact@v4
252+
with:
253+
name: win64.zip
254+
path: build/upload/win64.zip
265255

266256
- name: Upload Linux binaries
267257
if: matrix.platform == 'ubuntu-latest'

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if(POLICY CMP0057)
1717
cmake_policy(SET CMP0057 NEW)
1818
endif()
1919

20+
if (WINDOWS)
21+
cmake_policy(SET CMP0091 NEW)
22+
endif ()
23+
2024
#############################################
2125
# Display extra CMAKE info while configuring
2226
##############################################

conan-profiles/CI-CD/Linux-AMD64_profile.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ arch=x86_64
33
build_type=Release
44
compiler=gcc
55
compiler.version=11
6+
compiler.libcxx=libstdc++
67
os=Linux
78
[options]
89
fPIC=True
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[settings]
2+
os=Windows
3+
arch=x86_64
4+
compiler=clang
5+
compiler.version=16
6+
compiler.libcxx=libc++
7+
compiler.cppstd=17
8+
build_type=Release
9+
10+
[conf]
11+
tools.cmake.cmaketoolchain:generator=Ninja
12+
tools.build:compiler_executables={'c': 'clang', 'cpp': 'clang++'}
13+
tools.env.virtualenv:powershell=pwsh
14+
15+
[buildenv]
16+
CC=clang
17+
CXX=clang++

conanfile.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sys
2+
from conan import ConanFile
3+
from conan.tools.build import check_min_cppstd
4+
from conan.tools.cmake import CMake
5+
6+
class VCellODERecipe(ConanFile):
7+
name = "vcell-ode"
8+
version = "0.0.1"
9+
settings = "os", "compiler", "build_type", "arch"
10+
generators = "CMakeToolchain", "CMakeDeps"
11+
12+
options = {"shared": [True, False],
13+
"fPIC": [True, False],
14+
"with_fmt": [True, False],
15+
"include_messaging": [True, False],
16+
"generate_docs": [True, False]}
17+
18+
default_options = {"shared": False,
19+
"fPIC": True,
20+
"with_fmt": True,
21+
"include_messaging": True,
22+
"generate_docs": False}
23+
24+
def validate(self):
25+
check_min_cppstd(self, "17")
26+
27+
def build(self):
28+
cmake = CMake(self)
29+
cmake.definitions["OPTION_TARGET_MESSAGING"] = "ON" if self.options.include_messaging else "OFF"
30+
cmake.definitions["OPTION_TARGET_DOCS"] = "ON" if self.options.generate_docs else "OFF"
31+
32+
def requirements(self):
33+
if self.options.include_messaging:
34+
self.requires("libcurl/[<9.0]")
35+
self.requires("zlib/1.3.1")
36+
37+
def build_requirements(self):
38+
self.tool_requires("cmake/[>=3.13]")
39+
self.tool_requires("ninja/1.12.1")
40+
41+
def config_options(self):
42+
if self.settings.os == "Windows":
43+
del self.options.fPIC
44+
if self.options.include_messaging:
45+
print("Warning: Windows-builds do not currently support messaging. Building anyway", file=sys.stderr)
46+
47+
48+
def configure(self):
49+
if self.options.shared:
50+
# If os=Windows, fPIC will have been removed in config_options()
51+
# use rm_safe to avoid double delete errors
52+
self.options.rm_safe("fPIC")

conanfile.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)