diff --git a/conanfile.py b/conanfile.py index f040da2..886ecd7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -45,8 +45,10 @@ def generate(self): "boost_thread*"], "thrift": ["thrift", "thriftd"], } - for req, dep in self.dependencies.items(): - self._import_dynamic_libs(dep, dldir, dependency_libs.get(req.ref.name, ["*"])) + licensedir = os.path.join(self.build_folder, "dist", "doc", "licenses") + for dep in self.dependencies.host.values(): + self._import_dynamic_libs(dep, dldir, dependency_libs.get(dep.ref.name, ["*"])) + self._import_license(dep, licensedir) if self.dependencies["libcosim"].options.proxyfmu: self._import_executables(self.dependencies["proxyfmu"], bindir, ["*"]) @@ -74,6 +76,22 @@ def _import_executables(self, dependency, target_dir, patterns=["*"]): files = copy(self, patternx, bindir, target_dir, keep_path=False) self._update_rpath(files, "$ORIGIN/../lib") + def _import_license(self, dependency, licenses_dir): + src_licenses_dir = os.path.join(dependency.package_folder, "licenses") + tgt_licenses_dir = os.path.join(licenses_dir, dependency.ref.name) + if os.path.isdir(src_licenses_dir): + # Copy the full contents of '/licenses/' if it exists, + # which it does for virtually all conan-center packages. + copy(self, "*", src_licenses_dir, tgt_licenses_dir) + else: + # Copy everything that looks like it might contain license and + # copyright information. + copy(self, "*licen?e*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*copying*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*notice*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*authors*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + copy(self, "*copyright*", dependency.package_folder, tgt_licenses_dir, keep_path=False) + def _update_rpath(self, files, new_rpath): if files and self.settings.os == "Linux": with VirtualBuildEnv(self).environment().vars(self).apply():