diff --git a/recipes/cgns/all/CMakeLists.txt b/recipes/cgns/3.x.x/CMakeLists.txt similarity index 100% rename from recipes/cgns/all/CMakeLists.txt rename to recipes/cgns/3.x.x/CMakeLists.txt diff --git a/recipes/cgns/all/conandata.yml b/recipes/cgns/3.x.x/conandata.yml similarity index 100% rename from recipes/cgns/all/conandata.yml rename to recipes/cgns/3.x.x/conandata.yml diff --git a/recipes/cgns/all/conanfile.py b/recipes/cgns/3.x.x/conanfile.py similarity index 91% rename from recipes/cgns/all/conanfile.py rename to recipes/cgns/3.x.x/conanfile.py index 72ba39fc8a3bdf..d84f48782f9611 100644 --- a/recipes/cgns/all/conanfile.py +++ b/recipes/cgns/3.x.x/conanfile.py @@ -1,5 +1,6 @@ import os from conans import ConanFile, CMake, tools +from conan.tools.files import rename required_conan_version = ">=1.29.1" @@ -9,7 +10,7 @@ class CgnsConan(ConanFile): name = "cgns" description = "Standard for data associated with the numerical solution " \ "of fluid dynamics equations." - topics = ("conan", "cgns", "data", "cfd", "fluids") + topics = ("cgns", "data", "cfd", "fluids") homepage = "http://cgns.org/" license = "Zlib" url = "https://github.com/conan-io/conan-center-index" @@ -49,11 +50,11 @@ def configure(self): def requirements(self): if self.options.with_hdf5: - self.requires("hdf5/1.12.0") + self.requires("hdf5/1.12.1") def source(self): tools.get(**self.conan_data["sources"][self.version]) - os.rename("CGNS-" + self.version, self._source_subfolder) + rename(self, "CGNS-" + self.version, self._source_subfolder) def _configure_cmake(self): if self._cmake: @@ -87,6 +88,7 @@ def package(self): os.remove(os.path.join(self.package_folder, "include", "cgnsBuild.defs")) 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 diff --git a/recipes/cgns/all/patches/fix_find_hdf5.patch b/recipes/cgns/3.x.x/patches/fix_find_hdf5.patch similarity index 100% rename from recipes/cgns/all/patches/fix_find_hdf5.patch rename to recipes/cgns/3.x.x/patches/fix_find_hdf5.patch diff --git a/recipes/cgns/all/patches/fix_static_or_shared.patch b/recipes/cgns/3.x.x/patches/fix_static_or_shared.patch similarity index 100% rename from recipes/cgns/all/patches/fix_static_or_shared.patch rename to recipes/cgns/3.x.x/patches/fix_static_or_shared.patch diff --git a/recipes/cgns/all/test_package/CMakeLists.txt b/recipes/cgns/3.x.x/test_package/CMakeLists.txt similarity index 100% rename from recipes/cgns/all/test_package/CMakeLists.txt rename to recipes/cgns/3.x.x/test_package/CMakeLists.txt diff --git a/recipes/cgns/all/test_package/conanfile.py b/recipes/cgns/3.x.x/test_package/conanfile.py similarity index 88% rename from recipes/cgns/all/test_package/conanfile.py rename to recipes/cgns/3.x.x/test_package/conanfile.py index b4c9865828e628..eb0e78ff988d89 100644 --- a/recipes/cgns/all/test_package/conanfile.py +++ b/recipes/cgns/3.x.x/test_package/conanfile.py @@ -13,6 +13,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/cgns/all/test_package/test_package.cpp b/recipes/cgns/3.x.x/test_package/test_package.cpp similarity index 100% rename from recipes/cgns/all/test_package/test_package.cpp rename to recipes/cgns/3.x.x/test_package/test_package.cpp diff --git a/recipes/cgns/4.x.x/conandata.yml b/recipes/cgns/4.x.x/conandata.yml new file mode 100644 index 00000000000000..4b42dc8ab7ce22 --- /dev/null +++ b/recipes/cgns/4.x.x/conandata.yml @@ -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" diff --git a/recipes/cgns/4.x.x/conanfile.py b/recipes/cgns/4.x.x/conanfile.py new file mode 100644 index 00000000000000..cf19231332ad1f --- /dev/null +++ b/recipes/cgns/4.x.x/conanfile.py @@ -0,0 +1,141 @@ +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) + if self.should_configure: + # 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) + if self.should_build: + 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 diff --git a/recipes/cgns/4.x.x/patches/4.3.0-fixes.patch b/recipes/cgns/4.x.x/patches/4.3.0-fixes.patch new file mode 100644 index 00000000000000..ecfea2a2bfd1d8 --- /dev/null +++ b/recipes/cgns/4.x.x/patches/4.3.0-fixes.patch @@ -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 # diff --git a/recipes/cgns/4.x.x/test_package/CMakeLists.txt b/recipes/cgns/4.x.x/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..9d13f5fdc4323f --- /dev/null +++ b/recipes/cgns/4.x.x/test_package/CMakeLists.txt @@ -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}) diff --git a/recipes/cgns/4.x.x/test_package/conanfile.py b/recipes/cgns/4.x.x/test_package/conanfile.py new file mode 100644 index 00000000000000..eb0e78ff988d89 --- /dev/null +++ b/recipes/cgns/4.x.x/test_package/conanfile.py @@ -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) diff --git a/recipes/cgns/4.x.x/test_package/test_package.cpp b/recipes/cgns/4.x.x/test_package/test_package.cpp new file mode 100644 index 00000000000000..89b847fc14ad8e --- /dev/null +++ b/recipes/cgns/4.x.x/test_package/test_package.cpp @@ -0,0 +1,21 @@ +#include + +#include + +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; +} diff --git a/recipes/cgns/config.yml b/recipes/cgns/config.yml index d212293f8478bd..8441e3116e8926 100644 --- a/recipes/cgns/config.yml +++ b/recipes/cgns/config.yml @@ -1,3 +1,5 @@ versions: "3.4.1": - folder: all + folder: 3.x.x + "4.3.0": + folder: 4.x.x