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

Add catalyst library #22415

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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"
101 changes: 101 additions & 0 deletions recipes/catalyst/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from conan import ConanFile
from conan.errors import ConanException
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 validate(self):
# OpenMPI is not yet conan 2.0 compatible, so raise an exception in case its used
if self.options.use_mpi:
raise ConanException("MPI is not yet supported by the Catalyst recipe")

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")


if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("dl")

if self.settings.os == "Windows" and self.settings.build_type == "Debug":
self.cpp_info.libs = [f"catalystd"]

Check warning on line 92 in recipes/catalyst/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Using an f-string that does not have any interpolated variables
else:
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"
9 changes: 9 additions & 0 deletions recipes/catalyst/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_link_libraries(${PROJECT_NAME} PUBLIC catalyst::catalyst ${CMAKE_DL_LIBS})
target_link_libraries(${PROJECT_NAME} PUBLIC catalyst::catalyst)

Add a system_libs dependency instead.

if self.settings.os in ["Linux", "FreeBSD"]:
    self.cpp_info.system_libs.append("dl")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work in Windows?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Windows does not require linking against an additional library for loading of dynamic libraries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjcasmar please take a look at the comment above. I think it is the only thing missing in this PR

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"