-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade to Conan 2. Fixes #54. * Run tests in CI * Use libcosim stable, simplify build procedure * Drop explicit dependency on Boost * Match error behaviour of old boost::fibers-based code
- Loading branch information
1 parent
af43aeb
commit 305246c
Showing
6 changed files
with
133 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
|
||
.idea | ||
cmake-build-*/ | ||
|
||
build/ | ||
CMakeUserPresets.json | ||
|
||
### Vim | ||
*.swp | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,23 @@ | ||
libcosimc - OSP C co-simulation API | ||
=================================== | ||
![libcosimc CI Conan](https://github.com/open-simulation-platform/libcosimc/workflows/libcosimc%20CI%20Conan/badge.svg) | ||
This repository contains the OSP C library for co-simulations which wraps and exposes a subset of the [`libcosim`] | ||
library's functions. | ||
|
||
This repository contains the [OSP] C library for co-simulations, which wraps and | ||
exposes a subset of the [libcosim] C++ library's functions. | ||
|
||
See [`CONTRIBUTING.md`] for contributor guidelines and [`LICENSE`] for | ||
terms of use. | ||
|
||
|
||
|
||
How to build | ||
------------ | ||
Please read the [libcosim build instructions]. The commands you should run | ||
to build libcosimc are exactly the same, except that the option you need to | ||
add to `conan install` to enable [proxy-fmu] support is | ||
`--options="libcosim/*:proxyfmu=True`. | ||
|
||
`libcosimc` can be built in the same way as libcosim with the following differences in [step 2] | ||
|
||
To include FMU-proxy support use `-o libcosim:'proxyfmu=True'` when installing dependencies in | ||
|
||
conan install .. -o libcosim:'proxyfmu=True' --build=missing | ||
|
||
When running cmake use `-DLIBCOSIMC_USING_CONAN=TRUE` | ||
|
||
[`CONTRIBUTING.md`]: ./CONTRIBUTING.md | ||
[libcosim]: https://github.com/open-simulation-platform/libcosim | ||
[libcosim build instructions]: https://github.com/open-simulation-platform/libcosim#how-to-build | ||
[`LICENSE`]: ./LICENSE | ||
[Step 2]: https://github.com/open-simulation-platform/libcosim#step-2-prepare-build-system | ||
[`libcosim`]: https://github.com/open-simulation-platform/libcosim | ||
[OSP]: https://opensimulationplatform.com/ | ||
[proxy-fmu]: https://github.com/open-simulation-platform/proxy-fmu/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,87 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
from os import path | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.env import VirtualRunEnv | ||
from conan.tools.files import load | ||
|
||
|
||
class LibCosimCConan(ConanFile): | ||
# Basic package info | ||
name = "libcosimc" | ||
|
||
def set_version(self): | ||
self.version = load(self, os.path.join(self.recipe_folder, "version.txt")).strip() | ||
|
||
# Metadata | ||
license = "MPL-2.0" | ||
author = "osp" | ||
exports = "version.txt" | ||
scm = { | ||
"type": "git", | ||
"url": "auto", | ||
"revision": "auto" | ||
} | ||
description = "A C wrapper for libcosim, a co-simulation library for C++" | ||
|
||
# Binary configuration | ||
package_type = "library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "virtualrunenv" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": True, | ||
"fPIC": True, | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
self.options["*"].shared = self.options.shared | ||
|
||
# Dependencies/requirements | ||
tool_requires = ( | ||
"cmake/[>=3.15]", | ||
"doxygen/[>=1.8]", | ||
) | ||
requires = ( | ||
"libcosim/0.10.2@osp/stable" | ||
) | ||
"libcosim/0.10.3@osp/testing-bugfix_transitive-libs-boost", | ||
) | ||
|
||
def set_version(self): | ||
self.version = tools.load(path.join(self.recipe_folder, "version.txt")).strip() | ||
# Exports | ||
exports = "version.txt" | ||
exports_sources = "*" | ||
|
||
def imports(self): | ||
binDir = os.path.join("output", str(self.settings.build_type).lower(), "bin") | ||
self.copy("*.dll", dst=binDir, keep_path=False) | ||
self.copy("*.pdb", dst=binDir, keep_path=False) | ||
# Build steps | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
|
||
def configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.definitions["LIBCOSIMC_USING_CONAN"] = "ON" | ||
cmake.configure() | ||
return cmake | ||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = self.configure_cmake() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
cmake.build(target="doc") | ||
if self._is_tests_enabled(): | ||
env = VirtualRunEnv(self).environment() | ||
env.define("CTEST_OUTPUT_ON_FAILURE", "ON") | ||
with env.vars(self).apply(): | ||
cmake.test() | ||
|
||
# Packaging | ||
def package(self): | ||
cmake = self.configure_cmake() | ||
cmake = CMake(self) | ||
cmake.install() | ||
cmake.build(target="install-doc") | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = [ "cosimc" ] | ||
# Ensure that consumers use our CMake package configuration files | ||
# rather than ones generated by Conan. | ||
self.cpp_info.set_property("cmake_find_mode", "none") | ||
self.cpp_info.builddirs.append(".") | ||
|
||
# Helper functions | ||
def _is_tests_enabled(self): | ||
return os.getenv("LIBCOSIMC_RUN_TESTS_ON_CONAN_BUILD", "False").lower() in ("true", "1") |
Oops, something went wrong.