Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug of being unable to find the vehicle scripts when collecting csharp module files and small update to C# demo readme #551

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/demos/csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function(CollectCSharpFiles out_list module_list)
endif()

# Vehicle module
list (FIND module_list "postprocess" index)
list (FIND module_list "vehicle" index)
if (${index} GREATER -1)
set(Chrono_CSHARP_VEHICLE_DIR "${PROJECT_BINARY_DIR}/chrono_csharp/vehicle")
file(GLOB Chrono_CSHARP_VEHICLE_SOURCES
Expand Down
4 changes: 4 additions & 0 deletions src/demos/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ Currently, these are:
- the Chrono::Vehicle module

To generate the necessary C# scripts and associated libraries, set `CH_ENABLE_MODULE_CSHARP` to `ON` and also enable any other desired Chrono module (Irrlicht and/or Vehicle). The resulting C# scripts and associated libraries can then be used in external C# programs that leverage the exposed Chrono functionality, or else embedded in a Unity project.

When using MS Visual Studio, in order to build the C# demos included in the main Chrono solution, firstly build the core modules. When complete, attempt to build a C# demo to trigger Cmake GLOB update and a regeneration of all dependencies (i.e. the SIG generated .cs builds). Reload again and then proceed to build demos.

NB. If using the irrlicht module, ensure you manually copy the Irrlicht.dll to the build folder (or point to it in the system PATH), otherwise the demos will present an "unhandled exception error" stating an inability to load the dll 'Chrono_csharp_vehicle' for example. This is somewhat misleading, as it is not an error with Chrono - check you have correctly placed the Irrlicht (or any other required component dll) where the program can find it.
5 changes: 4 additions & 1 deletion src/demos/csharp/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ CollectCSharpFiles(CHRONO_CSHARP_SOURCES "${MODULE_LIST}")

foreach(PROGRAM ${DEMOS})
add_executable(${PROGRAM} "${PROGRAM}.cs" ${CHRONO_CSHARP_SOURCES})
add_dependencies(${PROGRAM} Chrono_csharp_core)
# set dependencies, so latest SWIG always builds first
foreach(module IN LISTS MODULE_LIST)
add_dependencies(${PROGRAM} "Chrono_csharp_${module}")
endforeach()
endforeach()
5 changes: 4 additions & 1 deletion src/demos/csharp/mbs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ CollectCSharpFiles(CHRONO_CSHARP_SOURCES "${MODULE_LIST}")

foreach(PROGRAM ${DEMOS})
add_executable(${PROGRAM} "${PROGRAM}.cs" ${CHRONO_CSHARP_SOURCES})
add_dependencies(${PROGRAM} Chrono_csharp_core Chrono_csharp_irrlicht)
# set dependencies, so latest SWIG always builds first
foreach(module IN LISTS MODULE_LIST)
add_dependencies(${PROGRAM} "Chrono_csharp_${module}")
endforeach()
endforeach()
6 changes: 4 additions & 2 deletions src/demos/csharp/vehicle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ CollectCSharpFiles(CHRONO_CSHARP_SOURCES "${MODULE_LIST}")

foreach(PROGRAM ${DEMOS})
add_executable(${PROGRAM} "${PROGRAM}.cs" ${CHRONO_CSHARP_SOURCES})
add_dependencies(${PROGRAM} Chrono_csharp_core Chrono_csharp_irrlicht Chrono_csharp_vehicle Chrono_csharp_postprocess)

# Applying specific reference dependencies for CRGTerrain demos (uses dynamic objects)
if(HAVE_OPENCRG)
Expand All @@ -52,5 +51,8 @@ foreach(PROGRAM ${DEMOS})
find_package(Mono REQUIRED)
endif()
endif()

# set dependencies, so latest SWIG always builds first
foreach(module IN LISTS MODULE_LIST)
add_dependencies(${PROGRAM} "Chrono_csharp_${module}")
endforeach()
endforeach()