Skip to content

Commit

Permalink
(#11172) fix: package/ignition-math
Browse files Browse the repository at this point in the history
* fix: recipe component, cmake version variables

used in downstream dependencies

* fix: url's and sha's

and component requires correct dependencies

* fix: hooks warning

    declare build_dirs before build_modules

* chore: apply review suggestion

* chore: apply review suggestions

use tools.get to rename folder

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* fix: remove tools.rename  method

Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
ggulgulia and uilianries authored Jun 26, 2022
1 parent 486f5ad commit 944ac28
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 44 deletions.
8 changes: 4 additions & 4 deletions recipes/ignition-math/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
sources:
"6.7.0":
url: "https://github.com/ignitionrobotics/ign-math/archive/ignition-math6_6.7.0.tar.gz"
sha256: "8456af51cbb128d7468d65b55124af7a235f052214ac2a239c3f23197416f2d2"
url: "https://github.com/gazebosim/gz-math/archive/ignition-math6_6.7.0.tar.gz"
sha256: "e5dac5aca6a117af8bd07ebca6e4ec8255682453487bf8d706bdb0315d17d6af"
"6.10.0":
url: "https://github.com/ignitionrobotics/ign-math/archive/refs/tags/ignition-math6_6.10.0.tar.gz"
sha256: "9e00284cd6d51afe190165b2b44258e19bd4a28781cbacf21fd6b0bae43c16aa"
url: "https://github.com/gazebosim/gz-math/archive/ignition-math6_6.10.0.tar.gz"
sha256: "94e853e1dfba97ebec4b6152691a89af1e94660b02f4ecdf04356b763c2848bd"
patches:
"6.7.0":
- base_path: "source_subfolder"
Expand Down
96 changes: 56 additions & 40 deletions recipes/ignition-math/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import conan.tools.files
from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import textwrap

required_conan_version = ">=1.29.1"

Expand All @@ -10,7 +11,7 @@ class IgnitionMathConan(ConanFile):
name = "ignition-math"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://ignitionrobotics.org/libs/math"
homepage = "https://gazebosim.org/libs/math"
description = " Math classes and functions for robot applications"
topics = ("ignition", "math", "robotics", "gazebo")
settings = "os", "compiler", "build_type", "arch"
Expand Down Expand Up @@ -76,12 +77,7 @@ def build_requirements(self):
self.build_requires("ignition-cmake/2.10.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
version_major = self.version.split(".")[0]
conan.tools.files.rename(self,
"ign-math-ignition-math{}_{}".format(version_major, self.version),
self._source_subfolder,
)
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
Expand All @@ -104,46 +100,66 @@ def package(self):
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_file_rel_path),
tools.Version(self.version))

# Remove MS runtime files
for dll_pattern_to_remove in ["concrt*.dll", "msvcp*.dll", "vcruntime*.dll"]:
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), dll_pattern_to_remove)

@staticmethod
def _create_cmake_module_variables(module_file, version):
content = textwrap.dedent("""\
set(ignition-math{major}_VERSION_MAJOR {major})
set(ignition-math{major}_VERSION_MINOR {minor})
set(ignition-math{major}_VERSION_PATCH {patch})
set(ignition-math{major}_VERSION_STRING "{major}.{minor}.{patch}")
set(ignition-math{major}_INCLUDE_DIRS "${{CMAKE_CURRENT_LIST_DIR}}/../../include/ignition/math{major}")
""".format(major=version.major, minor=version.minor, patch=version.patch))
tools.save(module_file, content)


def package_info(self):
version_major = tools.Version(self.version).major
self.cpp_info.names["cmake_find_package"] = "ignition-math{}".format(version_major)
self.cpp_info.names["cmake_find_package_multi"] = "ignition-math{}".format(version_major)

# cmake_find_package filename: ignition-math6-config.cmake
self.cpp_info.components["libignition-math"].libs = ["ignition-math{}".format(version_major)]
self.cpp_info.components["libignition-math"].includedirs.append("include/ignition/math{}".format(version_major))
self.cpp_info.components["libignition-math"].names["cmake_find_package"] = "ignition-math{}".format(version_major)
self.cpp_info.components["libignition-math"].names["cmake_find_package_multi"] = "ignition-math{}".format(version_major)
self.cpp_info.components["libignition-math"].names["pkg_config"] = "ignition-math{}".format(version_major)

# FIXME: create in file ignition-math6-eigen3-config.cmake
self.cpp_info.components["libignition-math-eigen3"].libs = []
self.cpp_info.components["libignition-math-eigen3"].requires = ["libignition-math", "eigen::eigen"]
self.cpp_info.components["libignition-math-eigen3"].names["cmake_find_package"] = "ignition-math{}-eigen3".format(version_major)
self.cpp_info.components["libignition-math-eigen3"].names["cmake_find_package_multi"] = "ignition-math{}-eigen3".format(version_major)
self.cpp_info.components["libignition-math-eigen3"].names["pkg_config"] = "ignition-math{}-eigen3".format(version_major)

# FIXME: create in file ignition-math6-all-config.cmake
self.cpp_info.components["libignition-math-all"].libs = []
self.cpp_info.components["libignition-math-all"].requires = ["libignition-math-eigen3"]
self.cpp_info.components["libignition-math-all"].names["cmake_find_package"] = "ignition-math{}-all".format(version_major)
self.cpp_info.components["libignition-math-all"].names["cmake_find_package_multi"] = "ignition-math{}-all".format(version_major)
self.cpp_info.components["libignition-math-all"].requires.append("eigen::eigen")
self.cpp_info.components["libignition-math-all"].requires.append("doxygen::doxygen")
self.cpp_info.components["libignition-math-all"].requires.append("swig::swig")

self.env_info.LD_LIBRARY_PATH.extend([
os.path.join(self.package_folder, x) for x in self.cpp_info.libdirs
])
self.env_info.PATH.extend([
os.path.join(self.package_folder, x) for x in self.cpp_info.bindirs
])
lib_name = f"ignition-math{version_major}"

self.cpp_info.names["cmake_find_package"] = lib_name
self.cpp_info.names["cmake_find_package_multi"] = lib_name
self.cpp_info.names["cmake_paths"] = lib_name

self.cpp_info.components[lib_name].names["cmake_find_package"] = lib_name
self.cpp_info.components[lib_name].names["cmake_find_package_multi"] = lib_name
self.cpp_info.components[lib_name].names["cmake_paths"] = lib_name
self.cpp_info.components[lib_name].libs = [lib_name]
self.cpp_info.components[lib_name].includedirs.append(os.path.join("include", "ignition", "math"+version_major))
self.cpp_info.components[lib_name].requires = ["swig::swig", "eigen::eigen", "doxygen::doxygen"]

self.cpp_info.components[lib_name].builddirs = [self._module_file_rel_dir]
self.cpp_info.components[lib_name].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components[lib_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
self.cpp_info.components[lib_name].build_modules["cmake_paths"] = [self._module_file_rel_path]

self.cpp_info.components["eigen3"].names["cmake_find_package"] = "eigen3"
self.cpp_info.components["eigen3"].names["cmake_find_package_multi"] = "eigen3"
self.cpp_info.components["eigen3"].names["cmake_paths"] = "eigen3"
self.cpp_info.components["eigen3"].includedirs.append(os.path.join("include", "ignition", "math"+version_major))
self.cpp_info.components["eigen3"].requires = ["eigen::eigen"]

self.cpp_info.components["eigen3"].builddirs = [self._module_file_rel_dir]
self.cpp_info.components["eigen3"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components["eigen3"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
self.cpp_info.components["eigen3"].build_modules["cmake_paths"] = [self._module_file_rel_path]

def validate(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8":
raise ConanInvalidConfiguration("sorry, M1 builds are not currently supported, give up!")

@property
def _module_file_rel_dir(self):
return os.path.join("lib", "cmake")

@property
def _module_file_rel_path(self):
return os.path.join(self._module_file_rel_dir, f"conan-official-{self.name}-variables.cmake")

0 comments on commit 944ac28

Please sign in to comment.