Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature conan recipe for fmi-library #1

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* eol=lf
53 changes: 53 additions & 0 deletions .github/workflows/ci-conan-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Linux GCC

on: [push, workflow_dispatch]

env:
CONAN_UPLOAD: ${{ secrets.CONAN_URL }}
CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }}
CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }}
CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git

jobs:
conan-with-gcc:
name: Conan
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
version: [2.4.1, 3.0-a.3]
build_type: [Debug, Release]
profile: [gcc]
compiler_version: [10, 11, 12]
with_fmus: ["with_fmus=True", "with_fmus=False"]
channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"]
container:
image: conanio/gcc${{ matrix.compiler_version }}-ubuntu18.04
options: -u 0
steps:
- uses: actions/checkout@v3
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install -y jq
pip3 install --upgrade setuptools pip
pip3 install --upgrade conan~=2.0
- name: Configure Conan and package name
run: |
conan remote add sintef ${{ env.CONAN_UPLOAD }}
echo "pkg_name=$(conan inspect -f json . | jq .name -r)" >> $GITHUB_ENV
- name: Conan create
run: |
git config --global --add safe.directory '*'
conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0
conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles
conan create -s build_type=${{ matrix.build_type }} \
-s compiler.version=${{ matrix.compiler_version }} \
-pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} \
--conf tools.build:skip_test=False \
-o ${{ env.pkg_name }}/*:${{ matrix.with_fmus }} \
--version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} \
-b missing -b outdated -b ${{ env.pkg_name }}* .
- name: Conan upload
run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force
48 changes: 48 additions & 0 deletions .github/workflows/ci-conan-msvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: Windows MSVC

on: [push, workflow_dispatch]

env:
CONAN_UPLOAD: ${{ secrets.CONAN_URL }}
CONAN_PASSWORD_SINTEF: ${{ secrets.CONAN_PASSWORD }}
CONAN_LOGIN_USERNAME_SINTEF: ${{ secrets.CONAN_USER }}
CONFIG_URL: https://github.com/sintef-ocean/conan-configs.git

jobs:
conan-with-msvc:
name: Conan
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
version: [2.4.1, 3.0-a.3]
build_type: [Debug, Release]
profile: [msvc17]
compiler_version: [192, 193]
with_fmus: ["with_fmus=True", "with_fmus=False"]
channel: ["${{ (github.head_ref || github.ref_name) == 'master' && 'stable' || 'testing' }}"]
steps:
- uses: actions/checkout@v4
- name: Install prerequisites
run: |
pip3 install --upgrade setuptools pip
pip3 install --upgrade conan~=2.0
- name: Configure Conan
run: |
conan remote add sintef ${{ env.CONAN_UPLOAD }}
$pkg_name=conan inspect -f json . | jq .name -r
echo "pkg_name=$pkg_name" >> $Env:GITHUB_ENV
- name: Conan create
run: |
conan config install ${{ env.CONFIG_URL }} --type git -sf conan2.0
conan config install ${{ env.CONFIG_URL }} --type git -sf profiles -tf profiles
conan create -s build_type=${{ matrix.build_type }} `
-s compiler.version=${{ matrix.compiler_version }} `
-pr:b=${{ matrix.profile }} -pr:h=${{ matrix.profile }} `
--conf tools.build:skip_test=True `
-o ${{ env.pkg_name }}/*:${{ matrix.with_fmus }} `
--version ${{ matrix.version }} --user sintef --channel ${{ matrix.channel }} `
-b missing -b outdated -b ${{ env.pkg_name }}* .
- name: Conan upload
run: conan upload --confirm -r sintef ${{ env.pkg_name }}* --force
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*~
test_package/build/
*.pyc
*.swp
*.swo
__pycache__
temp/
CMakeUserPresets.json
build/
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[![Linux GCC](https://github.com/sintef-ocean/conan-fmilibrary/workflows/Linux%20GCC/badge.svg)](https://github.com/sintef-ocean/conan-fmilibrary/actions?query=workflow%3A"Linux+GCC")
[![Windows MSVC](https://github.com/sintef-ocean/conan-fmilibrary/workflows/Windows%20MSVC/badge.svg)](https://github.com/sintef-ocean/conan-fmilibrary/actions?query=workflow%3A"Windows+MSVC")

[Conan.io](https://conan.io) recipe for [fmi-library](https://github.com/modelon-community/fmi-library).

## How to use this package

1. Add remote to conan's package [remotes](https://docs.conan.io/2/reference/commands/remote.html)

```bash
$ conan remote add sintef https://artifactory.smd.sintef.no/artifactory/api/conan/conan-local
```

2. Using [*conanfile.txt*](https://docs.conan.io/2/reference/conanfile_txt.html) and *cmake* in your project.

Add *conanfile.txt*:
```
[requires]
fmilib/2.4.1@sintef/stable

[options]
fmilib:with_fmus=True

[tool_requires]
cmake/[>=3.25.0]

[layout]
cmake_layout

[generators]
CMakeDeps
CMakeToolchain
VirtualBuildEnv

```
Insert into your *CMakeLists.txt* something like the following lines:
```cmake
cmake_minimum_required(VERSION 3.15)
project(TheProject CXX)

find_package(fmilib REQUIRED)

add_executable(the_executor code.cpp)
target_link_libraries(the_executor fmilibrary::fmilibrary)
```
Install and build e.g. a Release configuration (linux):
```bash
$ conan install . -s build_type=Release -pr:b=default
$ source build/Release/generators/conanbuild.sh
$ cmake --preset conan-release
$ cmake --build build/Release
$ source build/Release/generators/deactivate_conanbuild.sh
```

## Package options

| Option | Allowed values | Default |
|-----------|----------------|---------|
| shared | [True, False] | False |
| fPIC | [True, False] | True |
| with_fmus | [True, False] | False |

## Known recipe issues
48 changes: 48 additions & 0 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
sources:
"3.0-a.3":
url:
- "https://github.com/modelon-community/fmi-library/archive/refs/tags/3.0a3.tar.gz"
sha256: "bd9eeccc0a43e3a4acd1e03d864f8d53d42fad3ea1a3d4aef2f7e91eace5dea0"
"2.4.1":
url:
- "https://github.com/modelon-community/fmi-library/archive/refs/tags/2.4.1.tar.gz"
sha256: "8199d3e9423494b714b9c4e42f055248457a7c9162df3d4652000aa9a10b8316"
patches:
"3.0-a.3":
- patch_file: "patches/3.0-a.3-001-conanize-build-scripts.patch"
patch_description: "Conanize build scripts to externalize dependencies"
patch_type: "conan"
- patch_file: "patches/2.4.1-002-add-minizip-tools-as-functions.patch"
patch_description: "Add minizip and miniunz as functions instead of executables"
patch_type: "conan"
- patch_file: "patches/3.0-a.3-003-use-catch2-from-conan.patch"
patch_description: "Use conan catch2 over bundled variant"
patch_type: "conan"
- patch_file: "patches/3.0-a.3-004-build-static-c99-snprintf.patch"
patch_description: "Always build c99snprintf as static library"
patch_type: "bugfix"
patch_source: "https://github.com/open-simulation-platform/conan-fmilibrary/blob/master/build-static-c99snprintf.patch"
"2.4.1":
- patch_file: "patches/2.4.1-001-static-c99snprintf.patch"
patch_description: "Always build c99snprintf as static library"
patch_type: "bugfix"
patch_source: "https://github.com/open-simulation-platform/conan-fmilibrary/blob/master/build-static-c99snprintf.patch"
- patch_file: "patches/2.4.1-002-add-minizip-tools-as-functions.patch"
patch_description: "Add minizip and miniunz as functions instead of executables"
patch_type: "conan"
- patch_file: "patches/2.4.1-003-use-expat-from-conan.patch"
patch_description: "Use expat from conan instead of internal"
patch_type: "conan"
- patch_file: "patches/2.4.1-004-use-minizip-and-zlib-from-conan.patch"
patch_description: "Use minizip (and zlib) from conan instead of internal"
patch_type: "conan"
- patch_file: "patches/2.4.1-005-ensure-conan-friendly-cmakelists.patch"
patch_description: "Do minor changes to CMakeLists for conan friendliness"
patch_type: "conan"
- patch_file: "patches/2.4.1-006-link-external-targets.patch"
patch_description: "Link external targets no longer merged in fmilib"
patch_type: "conan"
- patch_file: "patches/2.4.1-007-add-missing-stdlib.h-include.patch"
patch_description: "exit() is defined in stdlib.h"
patch_type: "bugfix"
patch_source: "https://github.com/modelon-community/fmi-library/issues/95"
Loading
Loading