-
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
91c1f83
fmilibrary: add recipe for version 2.4.1
joakimono 8e69985
Remove alpha version remnants
joakimono fe5739c
Merge branch 'master' into fmilibrary/new-package
joakimono eed1b95
Add missing include and reviewer suggestion
joakimono 6f8fd9c
Merge branch 'master' into fmilibrary/new-package
joakimono bfc74d2
fmilibrary does not support armv8 Macos yet
joakimono 0ef2f16
Make zlib a direct dependency
joakimono 1cf10e7
Fix shared build windows
joakimono 8b3f0f5
Fix post package warnings
joakimono ed70246
Apply suggestions from code review
joakimono c3255d7
Move fmi copy to build and bump expat to 2.5.0
joakimono a616a6d
Address reviewer suggestions
joakimono 94483e4
enforce that fmilib is pure C
joakimono e3b9ce9
Merge branch 'master' into fmilibrary/new-package
joakimono 517dd95
Merge branch 'master' into fmilibrary/new-package
joakimono d918a85
Remove unneeded patch
joakimono 0a60219
Combine two patches working on same issue and file
joakimono 2070551
Let `with_fmus` option be False by default
joakimono b30ae79
Merge branch 'master' into fmilibrary/new-package
joakimono 36f1153
Merge branch 'master' into fmilibrary/new-package
joakimono 808db31
Merge branch 'master' into fmilibrary/new-package
joakimono b7f639b
Merge branch 'conan-io:master' into fmilibrary/new-package
joakimono 90bb8b3
Address review comments
joakimono e066842
Remove unused import
joakimono ad6a4bb
Address review comments
joakimono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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" | ||
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 |
---|---|---|
@@ -0,0 +1,131 @@ | ||
from os import path | ||
import posixpath | ||
from conan import ConanFile | ||
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 | ||
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") | ||
# c99_snprintf -> should be externalised | ||
|
||
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
|
||
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() | ||
|
||
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() | ||
|
||
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"] |
25 changes: 25 additions & 0 deletions
25
recipes/fmilibrary/all/patches/2.4.1-001-static-c99snprintf.patch
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 |
---|---|---|
@@ -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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.