-
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.
Updated cgns to 4.3.0, plus some recipe fixes
- Loading branch information
1 parent
b4b92c3
commit dbe315c
Showing
15 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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 @@ | ||
sources: | ||
"4.3.0": | ||
url: "https://github.com/CGNS/CGNS/archive/v4.3.0.tar.gz" | ||
sha256: "7709eb7d99731dea0dd1eff183f109eaef8d9556624e3fbc34dc5177afc0a032" | ||
patches: | ||
"4.3.0": | ||
- patch_file: "patches/4.3.0-fixes.patch" | ||
base_path: "source_subfolder" |
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,139 @@ | ||
import os | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout | ||
from conan.tools.files import apply_conandata_patches | ||
|
||
# TODO upgrade to new conan.* imports | ||
# not using the new get() yet: it seems to ignore the download cache (1.48.0) | ||
from conans.tools import get, remove_files_by_mask, rmdir, dos2unix | ||
|
||
|
||
required_conan_version = ">=1.47.0" | ||
|
||
|
||
class CgnsConan(ConanFile): | ||
name = "cgns" | ||
description = "Standard for data associated with the numerical solution " \ | ||
"of fluid dynamics equations." | ||
topics = ("cgns", "data", "cfd", "fluids") | ||
homepage = "http://cgns.org/" | ||
license = "Zlib" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_hdf5": [True, False], | ||
"parallel": [True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_hdf5": True, | ||
"parallel": False, | ||
} | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
if self.options.parallel: | ||
self.options["hdf5"].parallel = True | ||
self.options["hdf5"].enable_cxx = False # can't enable this with parallel | ||
|
||
def requirements(self): | ||
if self.options.with_hdf5: | ||
self.requires("hdf5/1.12.1") | ||
|
||
def validate(self): | ||
if self.options.parallel and not self.options.with_hdf5: | ||
raise ConanInvalidConfiguration("Parallel requires HDF5 with parallel enabled") | ||
|
||
def source(self): | ||
get(**self.conan_data["sources"][self.version], | ||
strip_root=True, | ||
destination=self._source_subfolder) | ||
|
||
def export_sources(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
self.copy(patch["patch_file"]) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
|
||
tc.variables["CMAKE_DEBUG_FIND_MODE"] = True | ||
tc.variables["CGNS_ENABLE_TESTS"] = False | ||
tc.variables["CGNS_BUILD_TESTING"] = False | ||
tc.variables["CGNS_ENABLE_FORTRAN"] = False | ||
tc.variables["CGNS_ENABLE_HDF5"] = self.options.with_hdf5 | ||
tc.variables["CGNS_BUILD_SHARED"] = self.options.shared | ||
tc.variables["CGNS_USE_SHARED"] = self.options.shared | ||
tc.variables["CGNS_ENABLE_PARALLEL"] = self.options.parallel | ||
tc.variables["CGNS_BUILD_CGNSTOOLS"] = False | ||
|
||
# Other flags, seen in appveyor.yml in source code, not currently managed. | ||
# CGNS_ENABLE_LFS:BOOL=OFF --- note in code: needed on 32 bit systems | ||
# CGNS_ENABLE_SCOPING:BOOL=OFF --- disabled in VTK's bundle | ||
# HDF5_NEED_ZLIB:BOOL=ON -- should be dealt with by cmake auto dependency management or something? | ||
|
||
tc.generate() | ||
|
||
|
||
def build(self): | ||
cmake = CMake(self) | ||
# conan complains about CRLF in this file, so fix it up | ||
dos2unix(os.path.join(self.source_folder,self._source_subfolder,"src","cgnstools","common", "winhtml.c")) | ||
apply_conandata_patches(self) | ||
cmake.configure(build_script_folder=self._source_subfolder) | ||
cmake.build() | ||
# OLD WAY: cmake.build(target="cgns_shared" if self.options.shared else "cgns_static") | ||
|
||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
self.copy("license.txt", dst="licenses", src=self._source_subfolder) | ||
|
||
# TODO do we need to export the variables in the generated cgnsBuild.defs ? | ||
# These would/could be used in consumers of the library... | ||
# Perhaps generate a conan-official-{}-variables.cmake file with these items? | ||
# From the file: | ||
#----------------------------------------------------------------------- | ||
# CGNS library build options. A 1 indicates that the library | ||
# was built with that option, a 0 indicates without | ||
# CGNS_DEBUG = debug | ||
# CGNS_LEGACY = legacy code (prior to 3.0) | ||
# CGNS_SCOPING = scoping of enums | ||
# CGNS_64BIT = 64 bit support | ||
# CGNS_FORTRAN = Fortran interface | ||
# CGNS_PARALLEL = parallel I/O | ||
# CGNS_BASESCOPE = Base scope for family and zone reference-to | ||
#----------------------------------------------------------------------- | ||
|
||
# And then delete the .defs file | ||
remove_files_by_mask(os.path.join(self.package_folder, "include"), "cgnsBuild.defs") | ||
|
||
# And delete the original cmake files, conan will sort that out | ||
rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
|
||
def package_info(self): | ||
# self.cpp_info.builddirs = [os.path.join("lib","cmake","cgns")] | ||
self.cpp_info.libs = ["cgnsdll" if self.settings.os == "Windows" and self.options.shared else "cgns"] | ||
if self.settings.os == "Windows" and self.options.shared: | ||
self.cpp_info.defines = ["CGNSDLL=__declspec(dllimport)"] # we could instead define USE_DLL but it's too generic |
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,22 @@ | ||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index 103cb1f..aae21a7 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -674,7 +674,9 @@ if(CGNS_BUILD_SHARED) | ||
endif() | ||
|
||
|
||
+if(NOT CGNS_BUILD_SHARED) | ||
set (install_targets cgns_static) | ||
+endif() | ||
if(CGNS_BUILD_SHARED) | ||
set(install_targets ${install_targets} cgns_shared) | ||
endif () | ||
@@ -738,7 +740,6 @@ install(EXPORT cgns-targets | ||
# Tools # | ||
######### | ||
|
||
-add_subdirectory(tools) | ||
|
||
######### | ||
# Tests # |
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.1) | ||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package ${CONAN_LIBS}) |
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 ConanFile, CMake, tools | ||
|
||
|
||
class CgnsTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "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,21 @@ | ||
#include <cgnslib.h> | ||
|
||
#include <cstdio> | ||
|
||
int main() { | ||
int indexFile; | ||
int indexBase; | ||
|
||
cg_open("test.cgns", CG_MODE_WRITE, &indexFile); | ||
|
||
cg_base_write(indexFile, "Base2D", 2, 3, &indexBase); | ||
|
||
// test a global variable | ||
printf("MassUnits: "); | ||
for (unsigned i = 0; i < NofValidMassUnits; ++i) { | ||
printf("%s ", MassUnitsName[i]); | ||
} | ||
printf("\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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
versions: | ||
"3.4.1": | ||
folder: all | ||
folder: 3.x.x | ||
"4.3.0": | ||
folder: 4.x.x |