-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first cantera test (this will not work)
This commit is intended to check how the pipeline works.
- Loading branch information
Showing
10 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# cantera-conan-wrapper | ||
# | ||
# SPDX-FileCopyrightText: Copyright 2023 German Aerospace Center (DLR) | ||
# SPDX-FileContributor: David Nelles <david.nelles@dlr.de> | ||
|
||
#Variable definition as proposed in | ||
#https://cmake.org/cmake/help/book/mastering-cmake/chapter/Finding%20Packages.html#built-in-find-modules | ||
|
||
set(Cantera_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||
mark_as_advanced(Cantera_ROOT_DIR) | ||
|
||
# Look for the header file. | ||
find_path(Cantera_INCLUDE_DIRS NAMES cantera/thermo.h) | ||
mark_as_advanced(Cantera_INCLUDE_DIRS) | ||
|
||
# Look for the library | ||
find_library(Cantera_LIBRARIES NAMES | ||
cantera_shared | ||
HINTS "${CMAKE_CURRENT_LIST_DIR}/bin" | ||
) | ||
mark_as_advanced(Cantera_LIBRARIES) | ||
|
||
# Look for the shared library | ||
# Since Cantera is a library and not a executable, this contains the shared labrary files (so and dll) | ||
find_file(Cantera_EXECUTABLE NAMES | ||
cantera_shared.dll | ||
libcantera_shared.so.3 | ||
HINTS "${CMAKE_CURRENT_LIST_DIR}/bin" "${CMAKE_CURRENT_LIST_DIR}/lib" | ||
) | ||
mark_as_advanced(Cantera_EXECUTABLE) | ||
|
||
# Look vor version number | ||
if(Cantera_INCLUDE_DIRS) | ||
set(CANTERA_VERSION_FILE "${Cantera_INCLUDE_DIRS}/cantera/base/config.h") | ||
if(EXISTS "${CANTERA_VERSION_FILE}") | ||
file(STRINGS "${CANTERA_VERSION_FILE}" cantera_version_str REGEX "^#define[\r\n\t ]+CANTERA_VERSION[\r\n\t ]+\".*\"") | ||
string(REGEX REPLACE "^#define[\r\n\t ]+CANTERA_VERSION[\r\n\t ]+\"([^\"]*)\".*" "\\1" Cantera_VERSION "${cantera_version_str}") | ||
unset(cantera_version_str) | ||
endif() | ||
endif() | ||
|
||
set(Cantera_VERSION_${Cantera_VERSION} TRUE) | ||
mark_as_advanced(Cantera_VERSION_${Cantera_VERSION}) | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set CANTERA_FOUND to TRUE if | ||
# all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cantera | ||
REQUIRED_VARS Cantera_LIBRARIES Cantera_INCLUDE_DIRS | ||
VERSION_VAR Cantera_VERSION | ||
) | ||
|
||
if(Cantera_FOUND) | ||
add_library(Cantera::cantera SHARED IMPORTED) | ||
set_target_properties(Cantera::cantera PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${Cantera_INCLUDE_DIRS} | ||
IMPORTED_LOCATION ${Cantera_EXECUTABLE} | ||
IMPORTED_IMPLIB ${Cantera_LIBRARIES} | ||
) | ||
endif(Cantera_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"3.0.0": | ||
url: "https://github.com/Cantera/cantera/archive/refs/tags/v3.0.0.tar.gz" | ||
sha256: "6d17cdef21dae9deaf91351260b68ccf7e264c37c6030c9d4bf26a2cefb2b905" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from conan import ConanFile | ||
from conan.tools.files import get | ||
|
||
class canteraRecipe(ConanFile): | ||
name = "cantera" | ||
tool_requires="scons/4.3.0" | ||
|
||
# Metadata | ||
author = ("David G. Goodwin", "Harry K. Moffat", "Ingmar Schoegl", "Raymond L. Speth", "Bryan W. Weber") | ||
url = "https://github.com/Cantera/cantera" | ||
description = "Cantera is an open-source collection of object-oriented software tools for problems involving chemical kinetics, thermodynamics, and transport processes." | ||
license = "LicenseRef-Cantera" | ||
|
||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
|
||
# Sources are located in the same place as this recipe, copy them to the recipe | ||
exports_sources = "cantera/SConstruct", "cantera/src/*", "cantera/include/*", "cantera/site_scons/*", "cantera/interfaces/*", "cantera/platform/*", "cantera/ext/*", "cantera/data/*", "cantera/License.txt", "FindCantera.cmake", "Kerosine5Step.yaml" | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
def requirements(self): | ||
self.requires("boost/1.83.0", headers=True, libs=False, build=False, visible=False) | ||
self.requires("fmt/10.1.1") | ||
self.requires("yaml-cpp/0.7.0") | ||
self.requires("eigen/3.4.0") | ||
self.requires("sundials/5.4.0") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) | ||
|
||
def generate(self): | ||
self.scons_extra_inc_dirs = \ | ||
self.dependencies["fmt"].cpp_info.includedirs +\ | ||
self.dependencies["yaml-cpp"].cpp_info.includedirs +\ | ||
self.dependencies["eigen"].cpp_info.includedirs | ||
|
||
self.scons_extra_lib_dirs = \ | ||
self.dependencies["fmt"].cpp_info.libdirs +\ | ||
self.dependencies["yaml-cpp"].cpp_info.libdirs +\ | ||
self.dependencies["eigen"].cpp_info.libdirs | ||
|
||
self.scons_sundials_include = self.dependencies["sundials"].cpp_info.includedirs[0] | ||
self.scons_sundials_libdir = self.dependencies["sundials"].cpp_info.libdirs[0] | ||
|
||
self.scons_boost_inc_dir = self.dependencies["boost"].cpp_info.includedirs[0] | ||
|
||
def layout(self): | ||
self.folders.source = "." | ||
self.folders.build = "build" | ||
self.cpp.source.includedirs = ["include"] | ||
|
||
def build(self): | ||
|
||
opt = "build -j4 " \ | ||
"prefix={} ".format(self.package_folder) +\ | ||
"libdirname=lib " \ | ||
"python_package=none " \ | ||
"f90_interface=n " \ | ||
"googletest=none " \ | ||
"versioned_shared_library=yes " \ | ||
"extra_inc_dirs={} ".format(';'.join(self.scons_extra_inc_dirs)) +\ | ||
"extra_lib_dirs={} ".format(';'.join(self.scons_extra_lib_dirs)) +\ | ||
"boost_inc_dir={} ".format(self.scons_boost_inc_dir) +\ | ||
"sundials_include={} ".format(self.scons_sundials_include) +\ | ||
"sundials_libdir={} ".format(self.scons_sundials_libdir) | ||
|
||
if self.settings.os == "Windows": | ||
opt = opt + "toolchain=msvc " | ||
cd_modifier = "/d" | ||
else: | ||
cd_modifier = "" | ||
|
||
if self.settings.build_type == "Debug": | ||
opt = opt + "optimize=no " | ||
else: | ||
opt = opt + "debug=no " | ||
|
||
self.run("cd {} {} && scons {}".format(cd_modifier, self.source_folder, opt)) | ||
|
||
def package(self): | ||
if self.settings.os == "Windows": | ||
cd_modifier = "/d" | ||
else: | ||
cd_modifier = "" | ||
|
||
self.run("cd {} {} && scons install".format(cd_modifier, self.source_folder)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package CXX) | ||
|
||
find_package(cantera REQUIRED) | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package PUBLIC cantera::cantera) | ||
target_compile_features(test_package PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
|
||
|
||
class TestPackage(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
#include <cantera/base/global.cpp> | ||
|
||
int main() | ||
{ | ||
const auto canteraVersion = Cantera::version() | ||
std::cout << "Cantera version: " << canteraVersion << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package CXX) | ||
|
||
find_package(canary REQUIRED) | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package PUBLIC cantera::cantera) | ||
target_compile_features(test_package PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
|
||
from conans import CMake, ConanFile, tools | ||
|
||
|
||
class TestPackage(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join(".", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
#include <cantera/base/global.cpp> | ||
|
||
int main() | ||
{ | ||
const auto canteraVersion = Cantera::version() | ||
std::cout << "Cantera version: " << canteraVersion << "\n"; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"v3.0.0": | ||
folder: all |