Skip to content

Commit 1d061f6

Browse files
committed
make boost link statically, add missing static definitions to libsbml/combine
1 parent 2c66f2e commit 1d061f6

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
TBB_SANITIZE: ${{ matrix.TBB_SANITIZE }}
8080
BUILD_TAG: ${{ matrix.BUILD_TAG }}
8181
steps:
82-
- uses: spatial-model-editor/setup-ci@2026.03.27
82+
- uses: spatial-model-editor/setup-ci@2026.03.30
8383
with:
8484
sme_deps_llvm: ${{ env.LLVM_VERSION }}
8585
sme_deps_qt: ${{ env.QT_VERSION }}

build.ps1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ function Invoke-CMakeConfigure {
6868
$configureArgs += "-DCMAKE_MSVC_RUNTIME_LIBRARY=$env:CMAKE_MSVC_RUNTIME_LIBRARY"
6969
}
7070
}
71+
if ($env:CMAKE_CXX_FLAGS) {
72+
if (-not ($configureArgs | Where-Object { $_ -like "-DCMAKE_CXX_FLAGS=*" })) {
73+
$configureArgs += "-DCMAKE_CXX_FLAGS=$env:CMAKE_CXX_FLAGS"
74+
}
75+
}
7176
if (Get-Command ccache -ErrorAction SilentlyContinue) {
7277
if (-not ($configureArgs | Where-Object { $_ -like "-DCMAKE_C_COMPILER_LAUNCHER=*" })) {
7378
$configureArgs += "-DCMAKE_C_COMPILER_LAUNCHER=ccache"
@@ -93,6 +98,27 @@ function Invoke-CMakeInstall {
9398
cmake --install .
9499
}
95100

101+
function Add-ImportedTargetCompileDefinitions {
102+
param(
103+
[Parameter(Mandatory)] [string]$TargetsFile,
104+
[Parameter(Mandatory)] [string]$TargetName,
105+
[Parameter(Mandatory)] [string[]]$Definitions
106+
)
107+
108+
if (-not (Test-Path $TargetsFile)) {
109+
throw "Could not find imported targets file: $TargetsFile"
110+
}
111+
112+
$targetsContents = Get-Content -Path $TargetsFile -Raw
113+
if ($targetsContents -like "*set_property(TARGET $TargetName APPEND PROPERTY*") {
114+
return
115+
}
116+
117+
$definitionList = ($Definitions | ForEach-Object { '"{0}"' -f $_ }) -join " "
118+
$patch = "`nset_property(TARGET $TargetName APPEND PROPERTY`n INTERFACE_COMPILE_DEFINITIONS $definitionList)`n"
119+
Add-Content -Path $TargetsFile -Value $patch
120+
}
121+
96122
function Resolve-LibraryPath {
97123
param(
98124
[Parameter(Mandatory)] [string[]]$Patterns,
@@ -237,6 +263,7 @@ Write-Host "TARGET_TRIPLE = $env:TARGET_TRIPLE"
237263
Write-Host "HOST_TRIPLE = $env:HOST_TRIPLE"
238264
Write-Host "MSVC_PLATFORM = $msvcPlatform"
239265
Write-Host "CMAKE_MSVC_RUNTIME_LIBRARY = $env:CMAKE_MSVC_RUNTIME_LIBRARY"
266+
Write-Host "CMAKE_CXX_FLAGS = $env:CMAKE_CXX_FLAGS"
240267
Write-Host "PYTHON_EXE = $pythonExe"
241268
Write-Host "LLVM_VERSION = $env:LLVM_VERSION"
242269
Write-Host "QT_VERSION = $env:QT_VERSION"
@@ -400,7 +427,7 @@ $boostB2Args = @(
400427
if ($env:BOOST_B2_OPTIONS) {
401428
$boostB2Args += $env:BOOST_B2_OPTIONS -split " "
402429
}
403-
$boostB2Args += @("link=static", "install")
430+
$boostB2Args += @("link=static", "runtime-link=static", "install")
404431
& .\b2 @boostB2Args
405432
Pop-Location
406433

@@ -437,6 +464,8 @@ $catch2Args = @(
437464
"-DBUILD_SHARED_LIBS=OFF",
438465
"-DCMAKE_INSTALL_PREFIX=$env:INSTALL_PREFIX",
439466
"-DCMAKE_PREFIX_PATH=$env:INSTALL_PREFIX",
467+
"-DCMAKE_CXX_STANDARD=20",
468+
"-DCMAKE_CXX_STANDARD_REQUIRED=ON",
440469
"-DCATCH_INSTALL_DOCS=OFF",
441470
"-DCATCH_CONFIG_NO_POSIX_SIGNALS=1",
442471
"-DCATCH_INSTALL_EXTRAS=ON"
@@ -695,6 +724,7 @@ $libsbmlArgs = @(
695724
Invoke-CMakeConfigure $libsbmlArgs
696725
Invoke-CMakeBuild
697726
Invoke-CMakeInstall
727+
Add-ImportedTargetCompileDefinitions -TargetsFile (Join-Path $env:INSTALL_PREFIX "lib\cmake\libsbml-static-targets.cmake") -TargetName "libsbml-static" -Definitions @("LIBSBML_STATIC=1", "LIBLAX_STATIC=1")
698728
Pop-Location
699729
Pop-Location
700730

@@ -723,6 +753,7 @@ $libCombineArgs = @(
723753
Invoke-CMakeConfigure $libCombineArgs
724754
Invoke-CMakeBuild
725755
Invoke-CMakeInstall
756+
Add-ImportedTargetCompileDefinitions -TargetsFile (Join-Path $env:BOOST_INSTALL_PREFIX "lib\cmake\libCombine-static-targets.cmake") -TargetName "libCombine-static" -Definitions @("LIBCOMBINE_STATIC=1")
726757
Pop-Location
727758
Pop-Location
728759

0 commit comments

Comments
 (0)