Skip to content

Commit

Permalink
Add catalyst package
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcasmar committed Jan 18, 2024
1 parent ba44013 commit ad3e752
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/catalyst/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
86 changes: 86 additions & 0 deletions recipes/catalyst/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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],
"use_mpi": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_mpi": False,
}

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"] = self.options.use_mpi
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"]

# Includes are installed under catalyst-2.0, but official documentation says we should use -I<install_dir>/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"
8 changes: 8 additions & 0 deletions recipes/catalyst/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
31 changes: 31 additions & 0 deletions recipes/catalyst/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
11 changes: 11 additions & 0 deletions recipes/catalyst/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <cstdlib>
#include <catalyst.hpp>
#include <conduit.h>

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;
}
8 changes: 8 additions & 0 deletions recipes/catalyst/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions recipes/catalyst/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions recipes/catalyst/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.0.0-rc4":
folder: "all"

0 comments on commit ad3e752

Please sign in to comment.