@@ -173,9 +173,31 @@ By default, any application linking to osimCommon will create an
173173written by OpenSim (incl. during static initialization) are written to 
174174both this file and the standard output streams."  OFF )
175175
176+ option (OPENSIM_DISABLE_STATIC_TYPE_REGISTRATION
177+ "Disable OpenSim from registering bundled `Object` types at static 
178+ initialization time. 
179+ 
180+ By default, the static initializer for each OpenSim library will 
181+ call `RegisterTypes_osimCommon`. This has the handy side-effect of 
182+ making all available `Object` types available at (post-static-init) 
183+ runtime, so that (e.g.) downstream code can immediately load XML 
184+ files. However, it has the drawback that downstream code cannot 
185+ control when, or in which order, registration happens, which can 
186+ (e.g.) prevent setting up application-level logging before registering 
187+ things. 
188+ 
189+ If this is set to `ON` (i.e. disable static type registration) then 
190+ downstream code *must* manually register the OpenSim types it plans 
191+ on using by calling `RegisterTypes_osimLIBRARY` (e.g. `RegisterTypes_osimActuators`), 
192+ or by manually registering each type (e.g. `Object::registerType(PhysicalOffsetFrame());`)."  OFF )
193+ mark_as_advanced (OPENSIM_DISABLE_STATIC_TYPE_REGISTRATION)
194+ 
176195if (OPENSIM_DISABLE_LOG_FILE)
177196    add_definitions (-DOPENSIM_DISABLE_LOG_FILE=1)
178197endif ()
198+ if (OPENSIM_DISABLE_STATIC_TYPE_REGISTRATION)
199+     add_definitions (-DOPENSIM_DISABLE_STATIC_TYPE_REGISTRATION=1)
200+ endif ()
179201
180202set (OPENSIM_BUILD_INDIVIDUAL_APPS_DEFAULT OFF )
181203if (WIN32 )
0 commit comments