Skip to content

Commit b4a5b49

Browse files
committed
copy VSG DLLs
1 parent b6cc70e commit b4a5b49

2 files changed

Lines changed: 57 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,31 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
654654
endif()
655655
endif()
656656

657+
# VSG DLLs (vsg, vsgImGui, vsgXchange, draco, etc.)
658+
if(HYDROCHRONO_ENABLE_VSG)
659+
# VSG_DLL_DIR is set by Chrono's find_package when VSG is found
660+
# Fall back to deriving from vsg_DIR if VSG_DLL_DIR is not set
661+
if(NOT DEFINED VSG_DLL_DIR OR VSG_DLL_DIR STREQUAL "")
662+
if(DEFINED vsg_DIR)
663+
# vsg_DIR points to lib/cmake/vsg, go up 3 levels to root then into bin
664+
get_filename_component(_vsg_root "${vsg_DIR}" DIRECTORY) # lib/cmake
665+
get_filename_component(_vsg_root "${_vsg_root}" DIRECTORY) # lib
666+
get_filename_component(_vsg_root "${_vsg_root}" DIRECTORY) # root
667+
set(VSG_DLL_DIR "${_vsg_root}/bin")
668+
endif()
669+
endif()
670+
671+
if(DEFINED VSG_DLL_DIR AND EXISTS "${VSG_DLL_DIR}")
672+
file(GLOB _vsg_dlls "${VSG_DLL_DIR}/*.dll")
673+
if(_vsg_dlls)
674+
message(STATUS "Installing VSG DLLs from: ${VSG_DLL_DIR}")
675+
install(FILES ${_vsg_dlls} DESTINATION bin COMPONENT runtime)
676+
endif()
677+
else()
678+
message(WARNING "HYDROCHRONO_ENABLE_VSG is ON but VSG_DLL_DIR not found. VSG DLLs will not be packaged.")
679+
endif()
680+
endif()
681+
657682
# Python DLLs, if Chrono::Parsers depends on it
658683
if(CHRONO_PARSERS_PYTHON)
659684
find_package(Python3 QUIET COMPONENTS Interpreter Development)

build.ps1

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ if ($LASTEXITCODE -ne 0) {
250250
Write-OK "Built in $buildSecs seconds"
251251

252252
# =============================================================================
253-
# Copy Third-Party DLLs (Irrlicht - not handled by Chrono's DLL copy command)
253+
# Copy Third-Party DLLs (not handled by Chrono's DLL copy command)
254254
# =============================================================================
255255

256256
$binPath = ".\build\bin\$BuildType"
@@ -270,28 +270,39 @@ if ($useIrrlicht) {
270270
}
271271

272272
if ($useVSG) {
273-
# Get VSG DLLs from vsgFramework bin directory
274-
# First try to find vsg_DIR from chrono config
275-
if ($chronoContent -match 'vsg_DIR\s+"([^"]+)"') {
276-
$vsgDir = $Matches[1]
277-
# vsg_DIR typically points to lib/cmake/vsg, so go up to find bin
278-
$vsgRoot = Split-Path (Split-Path (Split-Path $vsgDir))
279-
$vsgBinDir = Join-Path $vsgRoot "bin"
280-
281-
if (Test-Path $vsgBinDir) {
282-
$vsgDlls = Get-ChildItem -Path $vsgBinDir -Filter "*.dll" -ErrorAction SilentlyContinue
283-
$copiedCount = 0
284-
foreach ($dll in $vsgDlls) {
285-
$destDll = Join-Path $binPath $dll.Name
286-
if (-not (Test-Path $destDll)) {
287-
Copy-Item $dll.FullName $destDll -Force
288-
$copiedCount++
289-
}
290-
}
291-
if ($copiedCount -gt 0) {
292-
Write-OK "Copied $copiedCount VSG DLLs"
273+
# Get VSG DLL directory from Chrono config (set by find_package(vsg))
274+
# VSG_DLL_DIR is set by Chrono when it finds VSG
275+
$vsgDllDir = $null
276+
277+
if ($chronoContent -match 'VSG_DLL_DIR\s+([^\s\)]+)') {
278+
$vsgDllDir = $Matches[1].Trim('"')
279+
}
280+
281+
# Fallback: derive from vsg_DIR (lib/cmake/vsg -> bin)
282+
if (-not $vsgDllDir -or -not (Test-Path $vsgDllDir)) {
283+
if ($chronoContent -match 'vsg_DIR\s+"([^"]+)"') {
284+
$vsgCmakeDir = $Matches[1]
285+
# Go up from lib/cmake/vsg to root, then into bin
286+
$vsgRoot = Split-Path (Split-Path (Split-Path $vsgCmakeDir))
287+
$vsgDllDir = Join-Path $vsgRoot "bin"
288+
}
289+
}
290+
291+
if ($vsgDllDir -and (Test-Path $vsgDllDir)) {
292+
$vsgDlls = Get-ChildItem -Path $vsgDllDir -Filter "*.dll" -ErrorAction SilentlyContinue
293+
$copiedCount = 0
294+
foreach ($dll in $vsgDlls) {
295+
$destDll = Join-Path $binPath $dll.Name
296+
if (-not (Test-Path $destDll)) {
297+
Copy-Item $dll.FullName $destDll -Force
298+
$copiedCount++
293299
}
294300
}
301+
if ($copiedCount -gt 0) {
302+
Write-OK "Copied $copiedCount VSG DLLs from $vsgDllDir"
303+
}
304+
} else {
305+
Write-Warn "VSG enabled but could not find VSG DLL directory"
295306
}
296307
}
297308

0 commit comments

Comments
 (0)