How to export a model as an FMU is tool specific.
For example, see
- exporting FMUs from JModelica: http://www.jmodelica.org/api-docs/usersguide/1.17.0/ch04s02.html#models_sec_simple_fmume_compilation
- exporting FMUs from OpenModelica: https://www.openmodelica.org/doc/OpenModelicaUsersGuide/latest/fmi.html
- exporting an FMU from Dymola using a script, see https://github.com/lbl-srg/modelica-buildings/blob/master/Buildings/Resources/Scripts/Dymola/Fluid/FMI/Examples/FMUs/Fan.mos
- OMEdit and Dymola also allow to export FMUs from their GUI.
- exporting EnergyPlus as an FMU: http://simulationresearch.lbl.gov/fmu/EnergyPlus/export/userGuide/build.html