|
FhSim
3.1.0
Marine systems simulation
|
This document describes how to migrate a FhSim SimObject plugin project from fhsim 2.x to fhsim 3.1.0. It was derived from the migration of fhsim_environment and can serve as a checklist for other projects.
The fhsim repository ships a migration script that handles the bulk of mechanical changes automatically. Run it first, review its output, then apply:
The script handles:
| File type | Change applied |
|---|---|
conanfile.py / conanfile.txt | Version range updated to fhsim/[^3.1.0] |
CMakeLists.txt / .cmake | FhSim::fhsim → FhSim::simobject; FhSim::fhsim-testtools → FhSim::fhsim_testtools |
*.cpp / *.h | Header renames: CPrintDuringExec.h, CFhSimMgr.h, CExceptions.h, CAttributePath.h, CInputReader.h and the corresponding class names |
*.xml | <INTEGRATION> / </INTEGRATION> → <SIMULATION> / </SIMULATION>; jtype= → jac_type= |
Note: The script targets
FhSim::fhsim(capital F) in CMake files. Lowercasefhsim::fhsim(Conan CMakeDeps alias used in some older files) is not transformed — fix these manually (see step 3 below).
The script converts exact version numbers but may miss version-range syntax. Verify the requirements() function uses the new coordinates:
If any CMakeLists.txt still references fhsim::fhsim (all-lowercase), replace with FhSim::simobject:
In v3, the CMake target FhSim::fhsim has been split. Visualization headers (FhCamera.h, FhVisualization.h, etc.) are now provided by a separate FhSim::fhsim_vis component. Any library that compiles visualization source files must link this target:
FHSIM_FH_VISUALIZATION is set automatically by fhsim's fhsim-variables.cmake build module when fhsim was built with with_visualization=True.
The v3 visualization headers are installed under include/fhsim/visual/renderer/ and must be included with the full fhsim/ prefix:
| Old include | New include |
|---|---|
#include <CFhCamera.h> | #include <fhsim/visual/renderer/FhCamera.h> |
#include <CFhCameraController.h> | #include <fhsim/visual/renderer/FhCameraController.h> |
The CFhCamera class was also renamed to FhCamera. Update all declarations, definitions, and casts accordingly.
The shared-resource key used by GetSharedResource / SetPtr changed too:
The old ISimObjectCreator.h contained using std::string; at file scope, allowing unqualified string throughout downstream code. v3 removed this using declaration.
In headers — replace string with std::string:
In .cpp files — add a using declaration after includes (or qualify std::string at usage sites):
The SimObject base class member that holds the registered object name was renamed from m_SimObjectName (capital S) to m_simObjectName (lowercase s). Search and replace in all source files that access this member directly:
The utility header used by the SimObject DLL entry point was renamed:
If additional errors appear, check the error message against the categories in steps 4–8 above. The compiler error messages are usually descriptive enough to identify the root cause.
migrate_to_v3.py --applyconanfile.py version to fhsim/[^3.1.0]@sintef/stablefhsim::fhsim CMake targets → FhSim::simobjectFhSim::fhsim_vis link guard in visualization CMakeLists#include <CFhCamera.h> → #include <fhsim/visual/renderer/FhCamera.h>; update class/cast namesGetSharedResource("CFhCamera") → GetSharedResource("FhCamera")string → std::string in headers; add using std::string; in .cpp filesm_SimObjectName → m_simObjectName#include <dllLib.h> → #include <fhsim/DllLib.h>conan create passes cleanly