From 5e4e56dfe05737896966365d7412f83f3673a28a Mon Sep 17 00:00:00 2001 From: Juan Jose Casafranca Date: Thu, 18 Jan 2024 01:06:32 +0100 Subject: [PATCH] Add catalyst package --- recipes/catalyst/all/conandata.yml | 4 + recipes/catalyst/all/conanfile.py | 87 +++++++++++++++++++ .../catalyst/all/test_package/CMakeLists.txt | 9 ++ .../catalyst/all/test_package/conanfile.py | 31 +++++++ .../all/test_package/test_package.cpp | 11 +++ .../all/test_v1_package/CMakeLists.txt | 8 ++ .../catalyst/all/test_v1_package/conanfile.py | 18 ++++ recipes/catalyst/config.yml | 3 + 8 files changed, 171 insertions(+) create mode 100644 recipes/catalyst/all/conandata.yml create mode 100644 recipes/catalyst/all/conanfile.py create mode 100644 recipes/catalyst/all/test_package/CMakeLists.txt create mode 100644 recipes/catalyst/all/test_package/conanfile.py create mode 100644 recipes/catalyst/all/test_package/test_package.cpp create mode 100644 recipes/catalyst/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/catalyst/all/test_v1_package/conanfile.py create mode 100644 recipes/catalyst/config.yml diff --git a/recipes/catalyst/all/conandata.yml b/recipes/catalyst/all/conandata.yml new file mode 100644 index 0000000000000..22723597f6b59 --- /dev/null +++ b/recipes/catalyst/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.0.0-rc4": + url: "https://gitlab.kitware.com/api/v4/projects/5912/packages/generic/catalyst/v2.0.0-rc4/catalyst-v2.0.0-rc4.tar.gz" + sha256: "cb491e4ccd344156cc2494f65b9f38885598c16d12e1016c36e2ee0bc3640863" diff --git a/recipes/catalyst/all/conanfile.py b/recipes/catalyst/all/conanfile.py new file mode 100644 index 0000000000000..0fcab0f3d8246 --- /dev/null +++ b/recipes/catalyst/all/conanfile.py @@ -0,0 +1,87 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import get, copy, rmdir +import os + +required_conan_version = ">=1.53.0" + + +class CatalystConan(ConanFile): + name = "catalyst" + package_type = "library" + description = "Catalyst is an API specification developed for simulations (and other scientific data producers) to analyze and visualize data in situ." + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.kitware.com/paraview/catalyst" + topics = ("simulation", "visualization", "paraview", "in-situ", "in-transit") + license = "BSD-3" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def build_requirements(self): + self.tool_requires("cmake/[>3.26]") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def configure(self): + if self.options.get_safe("shared"): + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CATALYST_BUILD_REPLAY"] = False + tc.variables["CATALYST_BUILD_TESTING"] = False + tc.variables["CATALYST_BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["CATALYST_USE_MPI"] = False + tc.variables["CATALYST_BUILD_TOOLS"] = False + + # Catalyst adds by default catalyst_${VERSION} as suffix for static libs. Remove that + if not self.options.get_safe("shared"): + tc.variables["CATALYST_CUSTOM_LIBRARY_SUFFIX"] = "" + + tc.generate() + + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "License.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "catalyst", "cmake")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "catalyst") + self.cpp_info.set_property("cmake_target_name", "catalyst::catalyst") + self.cpp_info.set_property("pkg_config_name", "catalyst") + self.cpp_info.libs = ["catalyst"] + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("dl") + + # Includes are installed under catalyst-2.0, but official documentation says we should use -I/include/catalyst-2.0 + self.cpp_info.includedirs = ["include/catalyst-2.0"] + + self.cpp_info.names["cmake_find_package"] = "catalyst" + self.cpp_info.names["cmake_find_package_multi"] = "catalyst" diff --git a/recipes/catalyst/all/test_package/CMakeLists.txt b/recipes/catalyst/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e1b8b5c85e483 --- /dev/null +++ b/recipes/catalyst/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(catalyst REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PUBLIC catalyst::catalyst ${CMAKE_DL_LIBS}) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + diff --git a/recipes/catalyst/all/test_package/conanfile.py b/recipes/catalyst/all/test_package/conanfile.py new file mode 100644 index 0000000000000..543315cd0fbb8 --- /dev/null +++ b/recipes/catalyst/all/test_package/conanfile.py @@ -0,0 +1,31 @@ +import os +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/catalyst/all/test_package/test_package.cpp b/recipes/catalyst/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7b21cdc98792c --- /dev/null +++ b/recipes/catalyst/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include +#include +#include + +int main(void) { + conduit_cpp::Node node; + const auto init{catalyst_initialize(conduit_cpp::c_node(&node))}; + const auto exec{catalyst_execute(conduit_cpp::c_node(&node))}; + const auto finalize{catalyst_finalize(conduit_cpp::c_node(&node))}; + return EXIT_SUCCESS; +} diff --git a/recipes/catalyst/all/test_v1_package/CMakeLists.txt b/recipes/catalyst/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0d20897301b68 --- /dev/null +++ b/recipes/catalyst/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/catalyst/all/test_v1_package/conanfile.py b/recipes/catalyst/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..30ca1d12b0933 --- /dev/null +++ b/recipes/catalyst/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + tools.mkdir("logs/") + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/catalyst/config.yml b/recipes/catalyst/config.yml new file mode 100644 index 0000000000000..442dde7815ddd --- /dev/null +++ b/recipes/catalyst/config.yml @@ -0,0 +1,3 @@ +versions: + "2.0.0-rc4": + folder: "all"