fmi-bd2cmake
CMakeLists.txt generator that reads buildDescription.xml in FMI source code and generates build files for CMake.
Installation
Install from PyPI (when published):
pip install fmi-bd2cmake
Or install from source:
git clone https://github.com/jgillis/fmi-bd2cmake.git
cd fmi-bd2cmake
pip install -e .
Usage
Navigate to your FMU directory structure and run:
# Basic usage (looks for sources/buildDescription.xml in current directory)
fmi-bd2cmake
# Specify custom input/output paths
fmi-bd2cmake --input path/to/buildDescription.xml --output MyProject.txt
# Get help
fmi-bd2cmake --help
Expected Directory Structure
The tool expects an FMU source directory structure like:
your_fmu_directory/
├── sources/
│ ├── buildDescription.xml
│ ├── model.c
│ └── utils.c
└── CMakeLists.txt (generated)
After running fmi-bd2cmake, you can build with:
cmake -B build -DFMI_HEADERS_DIR=/path/to/fmi/headers .
cmake --build build
cmake --install build
This will create a shared library in binaries/{arch}/ directory as per FMI convention.
buildDescription.xml Format
The tool supports FMI 2.0 buildDescription.xml format with the following elements:
<fmiBuildDescription fmiVersion="2.0">
<BuildConfiguration description="Build config" modelIdentifier="my_model">
<SourceFileSet language="C99">
<SourceFile name="model.c"/>
<SourceFile name="utils.c"/>
<IncludeDirectory name="../include"/>
<PreprocessorDefinition name="DEBUG"/>
<PreprocessorDefinition name="VERSION" value="1.0"/>
</SourceFileSet>
<IncludeDirectory name="../../common"/>
<Library name="m"/>
<PreprocessorDefinition name="PLATFORM_LINUX"/>
</BuildConfiguration>
</fmiBuildDescription>
Features
- Standard library only: No external dependencies beyond Python standard library
- Cross-platform: Automatically detects target architecture (x86_64-linux, x86_64-windows, etc.)
- Full FMI support: Handles source files, include directories, preprocessor definitions, and libraries
- FMI headers support: Optional specification of external FMI header directory (typically containing fmi2Functions.h)
- Multiple source file sets: Supports different language/compiler settings per source set
- CMake best practices: Generates modern CMake with proper target properties
- Error handling: Clear error messages for missing files or invalid XML
FMI Headers Configuration
FMI header files (such as fmi2Functions.h) are typically not included in the FMU source distribution. The generated CMakeLists.txt automatically attempts to locate these headers and provides several ways to specify their location:
CMake Variable
cmake -DFMI_HEADERS_DIR=/path/to/fmi/headers .
Environment Variable
export FMI_HEADERS_DIR=/path/to/fmi/headers
cmake .
Automatic Discovery
The generated CMakeLists.txt will automatically search for FMI headers in common locations:
/usr/include/fmi2(Ubuntu/Debian libfmi-dev package)/usr/local/include/fmi2(custom installation)/opt/local/include/fmi2(MacPorts)../fmi-headers(relative to project)fmi-headers(in project directory)
The CMake variable takes precedence over the environment variable, which takes precedence over automatic discovery.
Examples
See the test_example/ and test_advanced/ directories for working examples.
Metadata
Release files for fmi-bd2cmake 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fmi_bd2cmake-0.1.0.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fmi_bd2cmake-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.1 kB
Release files / fmi_bd2cmake-0.1.0.tar.gz
| Download URL | fmi_bd2cmake-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c56700ca680c9b1044badcd01e996dcce235f8c9009b704197dd0c55e0dd9566
|
|
BLAKE2b-256 checksum How to use checksums |
246fb58484e292fcc7d71dff300538a1b9da40abe78b8a196309f3935b8585f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2025.
Transparency logRelease files / fmi_bd2cmake-0.1.0-py3-none-any.whl
| Download URL | fmi_bd2cmake-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
092d092c164b22c3020c029a7e4d97bf62549d33c68cfcfdca1bb99155bd6967
|
|
BLAKE2b-256 checksum How to use checksums |
48b67e6284864ab661115e60bdde44cb6e1c3d35251646a55949626c34cd0dcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2025.
Transparency log