-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fmilib: add recipe for version 2.4.1 #20256
Changes from 9 commits
91c1f83
8e69985
fe5739c
eed1b95
6f8fd9c
bfc74d2
0ef2f16
1cf10e7
8b3f0f5
ed70246
c3255d7
a616a6d
94483e4
e3b9ce9
517dd95
d918a85
0a60219
2070551
b30ae79
36f1153
808db31
b7f639b
90bb8b3
e066842
ad6a4bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||||||||||
sources: | ||||||||||||||
"2.4.1": | ||||||||||||||
url: | ||||||||||||||
- "https://github.com/modelon-community/fmi-library/archive/refs/tags/2.4.1.tar.gz" | ||||||||||||||
sha256: "8199d3e9423494b714b9c4e42f055248457a7c9162df3d4652000aa9a10b8316" | ||||||||||||||
patches: | ||||||||||||||
"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-enable-testing.patch" | ||||||||||||||
patch_description: "Ensure that tests can be run with cmake" | ||||||||||||||
patch_type: "conan" | ||||||||||||||
- patch_file: "patches/2.4.1-008-add-missing-stdlib.h-include.patch" | ||||||||||||||
patch_description: "exit() is defined in stdlib.h" | ||||||||||||||
patch_type: "conan" | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same, this patch should be sent to the upstream too. It's not a port to work with Conan, but an improvement to the original project. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will include a reference to patch_source. |
||||||||||||||
- patch_file: "patches/2.4.1-009-link-zlib-in-fmilib.patch" | ||||||||||||||
patch_description: "zlib must be linked explicitly due to minizip.c and miniunz.c inclusion" | ||||||||||||||
patch_type: "conan" | ||||||||||||||
- patch_file: "patches/2.4.1-010-install-runtime-to-bin.patch" | ||||||||||||||
patch_description: "install runtime (dll) to bin instead of lib" | ||||||||||||||
patch_type: "conan" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
from os import path | ||
import posixpath | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.apple import fix_apple_shared_install_name | ||
from conan.tools.microsoft import is_msvc_static_runtime, is_msvc | ||
from conan.tools.files import ( | ||
apply_conandata_patches, export_conandata_patches, get, copy, rmdir) | ||
from conan.tools.scm import Version | ||
from conan.tools.env import Environment, VirtualRunEnv | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class PackageConan(ConanFile): | ||
name = "fmilibrary" | ||
description = "C library for importing FMUs" | ||
license = "BSD-3-Clause" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/modelon-community/fmi-library" | ||
topics = ("fmi", "fmi-standard", "fmu") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_fmus": [True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_fmus": True | ||
} | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
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["expat"].shared = self.options.shared | ||
self.options["minizip"].shared = self.options.shared | ||
self.options["zlib"].shared = self.options.shared | ||
|
||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("fmi1/1.0.1") | ||
self.requires("fmi2/2.0.4") | ||
if self.version >= Version("3.0a2"): | ||
self.requires("fmi3/3.0.1") | ||
self.requires("expat/2.4.9") | ||
self.requires("minizip/1.2.13") | ||
self.requires("zlib/[>=1.2.11 <2]") | ||
# c99_snprintf -> should be externalised | ||
|
||
def validate(self): | ||
if self.settings.os == "Macos" and self.settings.arch == "armv8": | ||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise ConanInvalidConfiguration( | ||
f"{self.ref} does not support architecture " | ||
f"'{self.settings.arch}' on {self.settings.os}") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
|
||
copy(self, "fmiModel*.h", self.dependencies["fmi1"].cpp_info.components["modex"].includedirs[0], | ||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
path.join(self.build_folder, "fmis", "FMI1")) | ||
copy(self, "fmiPlatformTypes.h", self.dependencies["fmi1"].cpp_info.components["cosim"].includedirs[0], | ||
path.join(self.build_folder, "fmis", "FMI1")) | ||
copy(self, "fmiFunctions.h", self.dependencies["fmi1"].cpp_info.components["cosim"].includedirs[0], | ||
path.join(self.build_folder, "fmis", "FMI1")) | ||
copy(self, "*.h", self.dependencies["fmi2"].cpp_info.includedirs[0], | ||
path.join(self.build_folder, "fmis", "FMI2")) | ||
|
||
tc = CMakeToolchain(self) | ||
tc.variables["FMILIB_BUILD_STATIC_LIB"] = not self.options.shared | ||
tc.variables["FMILIB_BUILD_SHARED_LIB"] = self.options.shared | ||
tc.variables["FMILIB_BUILD_TESTS"] = self.options.with_fmus | ||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tc.variables["FMILIB_FMI_STANDARD_HEADERS"] = posixpath.join(self.build_folder, "fmis").replace("\\", "/") | ||
tc.variables["FMILIB_GENERATE_DOXYGEN_DOC"] = False | ||
|
||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# The variable is an option only if the following condition is true | ||
if not self.options.shared and not self.settings.os in ["Windows", "Macos"]: | ||
tc.variables["FMILIB_BUILD_FOR_SHARED_LIBS"] = self.options.get_safe("fPIC", False) | ||
|
||
if is_msvc(self): | ||
tc.variables["FMILIB_BUILD_WITH_STATIC_RTLIB"] = is_msvc_static_runtime(self) | ||
|
||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0026"] = "OLD" | ||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0045"] = "OLD" | ||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0046"] = "OLD" | ||
|
||
tc.generate() | ||
tc = CMakeDeps(self) | ||
tc.generate() | ||
|
||
vre = VirtualRunEnv(self) | ||
vre.generate(scope="build") | ||
uilianries marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
if not self.conf.get("tools.build:skip_test", default=True): | ||
env = Environment() | ||
env.define("CTEST_OUTPUT_ON_FAILURE", "ON") | ||
with env.vars(self).apply(): | ||
cmake.test() | ||
joakimono marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def package(self): | ||
copy(self, pattern="LICENSE.md", dst=path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
copy(self, pattern="FMILIB_Acknowledgements.txt", | ||
dst=path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
copy(self, pattern="*.fmu", dst=path.join(self.package_folder, "res", "fmus"), | ||
src=path.join(self.build_folder, "Testing"), keep_path=False) | ||
|
||
cmake = CMake(self) | ||
cmake.install() | ||
fix_apple_shared_install_name(self) | ||
|
||
rmdir(self, path.join(self.package_folder, "doc")) | ||
|
||
def package_info(self): | ||
if self.options.shared: | ||
self.cpp_info.libs = ["fmilib_shared"] | ||
else: | ||
self.cpp_info.libs = ["fmilib"] | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("dl") | ||
|
||
if self.settings.os in ["Windows"]: | ||
self.cpp_info.system_libs.append("shlwapi") | ||
|
||
self.cpp_info.resdirs = ["res"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From e4ad54090e455289ac23a45867b17c8dca88e704 Mon Sep 17 00:00:00 2001 | ||
From: Joakim Haugen <[email protected]> | ||
Date: Tue, 19 Sep 2023 08:59:53 +0200 | ||
Subject: [PATCH] Link c99snprintf statically | ||
|
||
--- | ||
ThirdParty/c99_snprintf/CMakeLists.txt | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/ThirdParty/c99_snprintf/CMakeLists.txt b/ThirdParty/c99_snprintf/CMakeLists.txt | ||
index 6f513b4..6c9b676 100644 | ||
--- a/ThirdParty/c99_snprintf/CMakeLists.txt | ||
+++ b/ThirdParty/c99_snprintf/CMakeLists.txt | ||
@@ -119,7 +119,7 @@ add_definitions(${DEFINES}) | ||
|
||
file(WRITE ${CMAKE_BINARY_DIR}/c99snprintf_defs "${DEFINES}") | ||
|
||
-add_library(c99snprintf c99-snprintf_1.1/snprintf.c) | ||
+add_library(c99snprintf STATIC c99-snprintf_1.1/snprintf.c) | ||
|
||
if(CYGWIN) | ||
message("not tested") | ||
-- | ||
2.30.2 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch should be sent to the upstream too. It's not a port to work with Conan, but an improvement to the original project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer needed, since ctest is not run in the recipe. Will be removed.