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

mfast: add 1.2.2 + drop maintenance of cci.20200824 + fix cross-build + modernize #8877

Merged
merged 10 commits into from
Mar 15, 2022
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
24 changes: 9 additions & 15 deletions recipes/mfast/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
sources:
"1.2.2":
url: "https://github.com/objectcomputing/mFAST/archive/refs/tags/v1.2.2.tar.gz"
sha256: "a7686c4d2e3121d7c8dd7f43b70424b55d4a1f6843179a6b0709658be27f39cb"
"1.2.1":
url: "https://github.com/objectcomputing/mFAST/archive/v1.2.1.tar.gz"
sha256: "e6ed19e629a33068b7ab5ebdbd860831f2f2b44b3b361068fbbbe975202a4851"
"cci.20200824":
url: "https://github.com/objectcomputing/mFAST/archive/4546f9b2f26cc7801fa63c05a7354ecbcb04410a.zip"
sha256: "ec2e34b0943066313db0a9cf2035ab8d5b28f9d46f0adfbb3ef9aa2a25280a4e"
patches:
"1.2.1":
- patch_file: "patches/00001-adapt-cmakelists.patch"
base_path: "source_subfolder"
- patch_file: "patches/00002-add-conan-libs-to-targets.patch"
base_path: "source_subfolder"
- patch_file: "patches/00003-remove-deprecated-boost-detail-endian.patch"
"1.2.2":
- patch_file: "patches/0001-fix-cmake-1.2.2.patch"
base_path: "source_subfolder"
"cci.20200824":
- patch_file: "patches/00001-adapt-cmakelists.cci.20200824.patch"
base_path: "source_subfolder"
- patch_file: "patches/00002-add-conan-libs-to-targets.cci.20200824.patch"
"1.2.1":
- patch_file: "patches/0001-fix-cmake-1.2.1.patch"
base_path: "source_subfolder"
- patch_file: "patches/00003-remove-deprecated-boost-detail-endian.cci.20200824.patch"
- patch_file: "patches/0002-remove-deprecated-boost-detail-endian.patch"
base_path: "source_subfolder"
- patch_file: "patches/00004-remove-cxx-std.cci.20200824.patch"
- patch_file: "patches/0003-mfast-sqlite3.patch"
base_path: "source_subfolder"
136 changes: 93 additions & 43 deletions recipes/mfast/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
from conans import ConanFile, CMake, tools
import glob
from conans.errors import ConanInvalidConfiguration
import os
import shutil
import textwrap

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.43.0"


class mFASTConan(ConanFile):
name = "mfast"
license = "LGPL-3.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://objectcomputing.com/"
description = "mFAST is a high performance C++ encoding/decoding library for FAST (FIX Adapted for STreaming)"\
" protocol"
topics = ("conan", "mFAST", "FAST", "FIX", "Fix Adapted for STreaming", "Financial Information Exchange",
"libraries", "cpp")
description = (
"mFAST is a high performance C++ encoding/decoding library for FAST "
"(FIX Adapted for STreaming) protocol"
)
topics = ("mfast", "fast", "fix", "fix-adapted-for-streaming",
"financial-information-exchange", "libraries", "cpp")

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_sqlite3": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_sqlite3": False,
}

short_paths = True

exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake"
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"
_cmake = None

@property
Expand All @@ -41,6 +43,20 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

@property
def _compilers_minimum_version(self):
return {
"gcc": "6",
"Visual Studio": "14",
"clang": "3.4",
"apple-clang": "5.1",
}

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -51,24 +67,40 @@ def configure(self):

def requirements(self):
self.requires("boost/1.75.0")
self.requires("tinyxml2/8.0.0")
self.requires("tinyxml2/9.0.0")
if self.options.with_sqlite3:
self.requires("sqlite3/3.37.2")

def validate(self):
if tools.Version(self.version) >= "1.2.2":
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 14)

def lazy_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
"mfast {} requires C++14, which your compiler does not support.".format(self.version)
)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob("mFAST-*/")[0]
os.rename(extracted_dir, self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)
self._cmake.definitions["BUILD_TESTS"] = False
self._cmake.definitions["BUILD_EXAMPLES"] = False
self._cmake.definitions["BUILD_PACKAGES"] = False
if self.version != "1.2.1":
if not self.settings.compiler.cppstd:
self._cmake.definitions["CMAKE_CXX_STANDARD"] = 14
else:
tools.check_min_cppstd(self, 14)
self._cmake.definitions["BUILD_SQLITE3"] = self.options.with_sqlite3
if tools.Version(self.version) >= "1.2.2" and not tools.valid_min_cppstd(self, 14):
self._cmake.definitions["CMAKE_CXX_STANDARD"] = 14
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

Expand Down Expand Up @@ -102,6 +134,8 @@ def package(self):
# [ ] MFAST_<component>_LIBRARY - particular component library
# [x] MFAST_EXECUTABLE - the fast_type_gen executable => done in _prepend_exec_target_in_fasttypegentarget()
self._prepend_exec_target_in_fasttypegentarget()

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._lib_targets_module_file),
{values["target"]:"mFAST::{}".format(values["target"]) for values in self._mfast_lib_components.values()}
Expand All @@ -120,7 +154,7 @@ def _fast_type_gen_target_file(self):
return os.path.join(self._new_mfast_config_dir, "FastTypeGenTarget.cmake")

def _extract_fasttypegentarget_macro(self):
if self.version == "1.2.1":
if tools.Version(self.version) < "1.2.2":
config_file_content = tools.load(os.path.join(self.package_folder, self._old_mfast_config_dir, "mFASTConfig.cmake"))
begin = config_file_content.find("macro(FASTTYPEGEN_TARGET Name)")
end = config_file_content.find("endmacro()", begin) + len("endmacro()")
Expand All @@ -139,7 +173,12 @@ def _prepend_exec_target_in_fasttypegentarget(self):
fast_type_rel_path = "{}bin/{}".format("".join(["../"] * module_folder_depth), fast_type_filename)
exec_target_content = textwrap.dedent("""\
if(NOT TARGET fast_type_gen)
get_filename_component(MFAST_EXECUTABLE "${{CMAKE_CURRENT_LIST_DIR}}/{fast_type_rel_path}" ABSOLUTE)
if(CMAKE_CROSSCOMPILING)
find_program(MFAST_EXECUTABLE fast_type_gen PATHS ENV PATH NO_DEFAULT_PATH)
endif()
if(NOT MFAST_EXECUTABLE)
get_filename_component(MFAST_EXECUTABLE "${{CMAKE_CURRENT_LIST_DIR}}/{fast_type_rel_path}" ABSOLUTE)
endif()
add_executable(fast_type_gen IMPORTED)
set_property(TARGET fast_type_gen PROPERTY IMPORTED_LOCATION ${{MFAST_EXECUTABLE}})
endif()
Expand Down Expand Up @@ -168,63 +207,70 @@ def _lib_targets_module_file(self):

@property
def _mfast_lib_components(self):
# TODO: improve accuracy of external requirements of each component
target_suffix = "_static" if not self.options.shared else ""
lib_suffix = "_static" if self.settings.os == "Windows" and not self.options.shared else ""
return {
components = {
"libmfast": {
"comp": "mfast",
"target": "mfast" + target_suffix,
"lib": "mfast" + lib_suffix,
"requires": ["boost::headers"]
"requires": ["boost::headers"],
},
"mfast_coder": {
"comp": "mfast_coder",
"target": "mfast_coder" + target_suffix,
"lib": "mfast_coder" + lib_suffix,
"requires": ["libmfast", "boost::headers"]
"requires": ["libmfast", "boost::headers"],
},
"mfast_xml_parser": {
"comp": "mfast_xml_parser",
"target": "mfast_xml_parser" + target_suffix,
"lib": "mfast_xml_parser" + lib_suffix,
"requires": ["libmfast", "boost::headers", "tinyxml2::tinyxml2"]
"requires": ["libmfast", "boost::headers", "tinyxml2::tinyxml2"],
},
"mfast_json": {
"comp": "mfast_json",
"target": "mfast_json" + target_suffix,
"lib": "mfast_json" + lib_suffix,
"requires": ["libmfast", "boost::headers"]
}
"requires": ["libmfast", "boost::headers"],
},
}
if self.options.with_sqlite3:
components.update({
"mfast_sqlite3": {
"comp": "mfast_sqlite3",
"target": "mfast_sqlite3" + target_suffix,
"lib": "mfast_sqlite3" + lib_suffix,
"requires": ["libmfast", "boost::headers", "sqlite3::sqlite3"],
},
})
return components

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "mFAST"
self.cpp_info.names["cmake_find_package_multi"] = "mFAST"
self.cpp_info.set_property("cmake_file_name", "mFAST")
self.cpp_info.set_property("cmake_build_modules", [self._fast_type_gen_target_file])

for conan_comp, values in self._mfast_lib_components.items():
target = values["target"]
comp = values["comp"]
lib = values["lib"]
requires = values["requires"]
self.cpp_info.components[conan_comp].names["cmake_find_package"] = target
self.cpp_info.components[conan_comp].names["cmake_find_package_multi"] = target
self.cpp_info.components[conan_comp].builddirs.append(self._new_mfast_config_dir)
self.cpp_info.components[conan_comp].build_modules["cmake"] = [self._fast_type_gen_target_file]
self.cpp_info.components[conan_comp].build_modules["cmake_find_package"] = [
self._lib_targets_module_file,
self._fast_type_gen_target_file
]
self.cpp_info.components[conan_comp].build_modules["cmake_find_package_multi"] = [
self._lib_targets_module_file,
self._fast_type_gen_target_file
]
self.cpp_info.components[conan_comp].set_property("cmake_file_name", target)
if comp != target:
# Also provide alias component for find_package(mFAST COMPONENTS ...) if static
self.cpp_info.components[conan_comp].set_property("cmake_target_aliases", [comp])
self.cpp_info.components[conan_comp].libs = [lib]
self.cpp_info.components[conan_comp].requires = requires
if self.options.shared:
self.cpp_info.components[conan_comp].defines = ["MFAST_DYN_LINK"]

# Also provide alias component for find_package(mFAST COMPONENTS ...) if static:
comp = values["comp"]
# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.components[conan_comp].names["cmake_find_package"] = target
self.cpp_info.components[conan_comp].names["cmake_find_package_multi"] = target
self.cpp_info.components[conan_comp].build_modules["cmake"] = [self._fast_type_gen_target_file]
build_modules = [self._lib_targets_module_file, self._fast_type_gen_target_file]
self.cpp_info.components[conan_comp].build_modules["cmake_find_package"] = build_modules
self.cpp_info.components[conan_comp].build_modules["cmake_find_package_multi"] = build_modules
if comp != target:
conan_comp_alias = conan_comp + "_alias"
self.cpp_info.components[conan_comp_alias].names["cmake_find_package"] = comp
Expand All @@ -235,3 +281,7 @@ def package_info(self):
self.cpp_info.components[conan_comp_alias].resdirs = []
self.cpp_info.components[conan_comp_alias].bindirs = []
self.cpp_info.components[conan_comp_alias].frameworkdirs = []

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "mFAST"
self.cpp_info.names["cmake_find_package_multi"] = "mFAST"

This file was deleted.

33 changes: 0 additions & 33 deletions recipes/mfast/all/patches/00001-adapt-cmakelists.patch

This file was deleted.

Loading