Skip to main content

CMakeLists.txt generator that reads buildDescription.xml in FMI source

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fmi_bd2cmake-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fmi_bd2cmake-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file fmi_bd2cmake-0.1.0.tar.gz.

File metadata

  • Download URL: fmi_bd2cmake-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fmi_bd2cmake-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c56700ca680c9b1044badcd01e996dcce235f8c9009b704197dd0c55e0dd9566
MD5 975ddc03254f47021696d34df3c773f9
BLAKE2b-256 246fb58484e292fcc7d71dff300538a1b9da40abe78b8a196309f3935b8585f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fmi_bd2cmake-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on jgillis/fmi-bd2cmake

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fmi_bd2cmake-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fmi_bd2cmake-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fmi_bd2cmake-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 092d092c164b22c3020c029a7e4d97bf62549d33c68cfcfdca1bb99155bd6967
MD5 0d097fb750b13664498c2a80b41cb402
BLAKE2b-256 48b67e6284864ab661115e60bdde44cb6e1c3d35251646a55949626c34cd0dcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fmi_bd2cmake-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on jgillis/fmi-bd2cmake

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page