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

[package] cgns/4.3.0: Updated release, plus some recipe fixes #10855

Merged
merged 25 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bbbbe05
cgns - add 4.3.0 and 'parallel' option
paulharris May 31, 2022
67a5d3a
Requires cmake_find_package on windows/msvc
paulharris Jun 16, 2022
44ce8ed
Bump HDF5 version
paulharris Jul 1, 2022
5d8dcd4
Bump HDF5 to 1.13.1
paulharris Jul 8, 2022
b8b7d3e
Lint fix
paulharris Jul 8, 2022
33a7254
- always set CMAKE_BUILD_TYPE
SSE4 Jul 9, 2022
6d53ee1
Small change to make v2 linter happy
paulharris Jul 10, 2022
ff79791
Fixing up components
paulharris Jul 21, 2022
54b6df6
Extra validation
paulharris Jul 21, 2022
7d8acc3
Minor fix for requirements
paulharris Jul 21, 2022
2a70c59
Don't auto-set these options - not required for CCI
paulharris Jul 21, 2022
ae88958
Adjustments for conan v2 migration
paulharris Jul 22, 2022
837300d
Attempt 2 for conan v2
paulharris Jul 22, 2022
3d1ac26
Attempt 3 for conan v2
paulharris Jul 22, 2022
53fdb89
Let conan set CMAKE_BUILD_TYPE
paulharris Jul 22, 2022
21e2a81
Don't forget CMakeDeps
paulharris Jul 22, 2022
a7d0ae7
Specify libdirs, even though it should be the default
paulharris Jul 23, 2022
4276c24
Whitespace to force CI rebuild, hopefully
paulharris Jul 23, 2022
38985b4
Tweak to deleting libcxx
paulharris Jul 23, 2022
3304b92
Back to try/except
paulharris Jul 23, 2022
66f5f8b
More tweaks to make good
paulharris Jul 23, 2022
3f7c20d
Switch to find_package(HDF5) for old cgns v3
paulharris Jul 29, 2022
b5863b8
Remove 3.4.1 support - too hard to make it work with conan v2 toolchain
paulharris Jul 29, 2022
03fbd48
Upgrading for conan v2
paulharris Oct 21, 2022
5ce298d
Fix for hdf5 library link patch
paulharris Oct 21, 2022
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
7 changes: 0 additions & 7 deletions recipes/cgns/all/CMakeLists.txt

This file was deleted.

14 changes: 6 additions & 8 deletions recipes/cgns/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
sources:
"3.4.1":
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain why did you need to drop 3.4.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't make it work with conan v1-v2 transition, I'm close to giving up ...
I am happy to not drop 3.4.1 but I can't keep spending time bashing my head against walls.

It is probably something very simple for someone else to fix...

url: "https://github.com/CGNS/CGNS/archive/v3.4.1.tar.gz"
sha256: "d32595e7737b9332243bd3de1eb8c018a272f620f09b289dea8292eba1365994"
"4.3.0":
url: "https://github.com/CGNS/CGNS/archive/v4.3.0.tar.gz"
sha256: "7709eb7d99731dea0dd1eff183f109eaef8d9556624e3fbc34dc5177afc0a032"
patches:
"3.4.1":
- patch_file: "patches/fix_find_hdf5.patch"
base_path: "source_subfolder"
- patch_file: "patches/fix_static_or_shared.patch"
base_path: "source_subfolder"
"4.3.0":
- patch_file: "patches/4.3.0-fix_find_hdf5.patch"
- patch_file: "patches/4.3.0-fix_static_or_shared.patch"
132 changes: 84 additions & 48 deletions recipes/cgns/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,92 +1,128 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir
import os
from conans import ConanFile, CMake, tools


required_conan_version = ">=1.29.1"

required_conan_version = ">=1.52.0"

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 = "data", "cfd", "fluids"
homepage = "http://cgns.org/"
license = "Zlib"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_hdf5": [True, False]
"with_hdf5": [True, False],
"parallel": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_hdf5": True
"with_hdf5": True,
"parallel": False,
}

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"
def export_sources(self):
export_conandata_patches(self)

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
try:
del self.options.fPIC
except Exception:
pass
try:
del self.settings.compiler.libcxx
except Exception:
pass
try:
del self.settings.compiler.cppstd
except Exception:
pass

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.with_hdf5:
self.requires("hdf5/1.12.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("CGNS-" + self.version, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self.requires("hdf5/1.13.1")

self._cmake = CMake(self)
self._cmake.definitions["CGNS_ENABLE_TESTS"] = False
self._cmake.definitions["CGNS_BUILD_TESTING"] = False
self._cmake.definitions["CGNS_ENABLE_FORTRAN"] = False
self._cmake.definitions["CGNS_ENABLE_HDF5"] = self.options.with_hdf5
self._cmake.definitions["CGNS_BUILD_SHARED"] = self.options.shared
self._cmake.definitions["CGNS_USE_SHARED"] = self.options.shared
self._cmake.definitions["CGNS_BUILD_CGNSTOOLS"] = False
self._cmake.configure()
def validate(self):
if self.info.options.parallel and not (self.info.options.with_hdf5 and self.dependencies["hdf5"].options.parallel):
raise ConanInvalidConfiguration("The option 'parallel' requires HDF5 with parallel=True")
if self.info.options.parallel and self.info.options.with_hdf5 and self.dependencies["hdf5"].options.enable_cxx:
raise ConanInvalidConfiguration("The option 'parallel' requires HDF5 with enable_cxx=False")

return self._cmake
def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)

def generate(self):
cmake = CMakeDeps(self)
cmake.generate()

tc = CMakeToolchain(self)
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
tc.generate()

# 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?

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
apply_conandata_patches(self)

cmake = self._configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build(target="cgns_shared" if self.options.shared else "cgns_static")

def package(self):
self.copy("license.txt", dst="licenses", src=self._source_subfolder)
copy(self, "license.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)

cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()

os.remove(os.path.join(self.package_folder, "include", "cgnsBuild.defs"))
rm(self, "cgnsBuild.defs", os.path.join(self.package_folder, "include"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
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
self.cpp_info.set_property("cmake_file_name", "CGNS")
self.cpp_info.set_property("cmake_target_name", "CGNS::CGNS")

if self.options.shared:
self.cpp_info.components["cgns_shared"].set_property("cmake_target_name", "CGNS::cgns_shared")
self.cpp_info.components["cgns_shared"].libs = ["cgnsdll" if self.settings.os == "Windows" else "cgns"]
self.cpp_info.components["cgns_shared"].libdirs = ["lib"]
if self.options.with_hdf5:
self.cpp_info.components["cgns_shared"].requires = ["hdf5::hdf5"]
if self.settings.os == "Windows":
# we could instead define USE_DLL but it's too generic
self.cpp_info.components["cgns_shared"].defines = ["CGNSDLL=__declspec(dllimport)"]
else:
self.cpp_info.components["cgns_static"].set_property("cmake_target_name", "CGNS::cgns_static")
self.cpp_info.components["cgns_static"].libs = ["cgns"]
self.cpp_info.components["cgns_static"].libdirs = ["lib"]
if self.options.with_hdf5:
self.cpp_info.components["cgns_static"].requires = ["hdf5::hdf5"]

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["cmake_find_package"] = "CGNS"
self.cpp_info.names["cmake_find_package_multi"] = "CGNS"
23 changes: 23 additions & 0 deletions recipes/cgns/all/patches/4.3.0-fix_find_hdf5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff -r -u a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt 2022-05-31 16:13:29.855723400 +0800
+++ b/src/CMakeLists.txt 2022-05-31 16:40:39.332447379 +0800
@@ -576,7 +576,7 @@
add_library(CGNS::cgns-static ALIAS cgns_static)
# Needed to work around a CMake > 3.8 bug on Windows with MSVS and Intel Fortran
set_property(TARGET cgns_static PROPERTY LINKER_LANGUAGE C)
-target_link_libraries(cgns_static PRIVATE $<$<BOOL:${CGNS_ENABLE_HDF5}>:hdf5::hdf5-${CG_HDF5_LINK_TYPE}>)
+target_link_libraries(cgns_static PRIVATE $<$<BOOL:${CGNS_ENABLE_HDF5}>:HDF5::HDF5>)

# Build a shared version of the library
if(CGNS_BUILD_SHARED)
@@ -592,8 +592,8 @@
target_compile_definitions(cgns_shared PRIVATE -DBUILD_DLL)
target_compile_definitions(cgns_shared INTERFACE -DUSE_DLL)
endif ()
- if (CGNS_ENABLE_HDF5 AND HDF5_LIBRARY)
- target_link_libraries(cgns_shared PUBLIC hdf5::hdf5-${CG_HDF5_LINK_TYPE} $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>)
+ if (CGNS_ENABLE_HDF5)
+ target_link_libraries(cgns_shared PUBLIC HDF5::HDF5 $<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>)
if(HDF5_NEED_ZLIB AND ZLIB_LIBRARY)
target_link_libraries(cgns_shared PUBLIC ${ZLIB_LIBRARY})
endif()
24 changes: 24 additions & 0 deletions recipes/cgns/all/patches/4.3.0-fix_static_or_shared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Enforces that either static or dynamic libs are built

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 #
19 changes: 0 additions & 19 deletions recipes/cgns/all/patches/fix_find_hdf5.patch

This file was deleted.

31 changes: 0 additions & 31 deletions recipes/cgns/all/patches/fix_static_or_shared.patch

This file was deleted.

5 changes: 2 additions & 3 deletions recipes/cgns/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(CGNS CONFIG REQUIRED)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package ${CONAN_LIBS})
target_link_libraries(test_package CGNS::CGNS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Because there are components I assume the headers are now being passed to the global target 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow.
Is CGNS::CGNS the "global target" ?
What should be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@prince-chrismc when you have time please, I'm not sure what you mean

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not being more clear, I was trying to see why the build fail when I left that comment...

CI failed because the header was not found, but I can see it being placed in the package... I am not sure why that is I was just tossing a suggestion... might be a bug that was fix in 1.50 thats not in CCI

🤷 sorry I am not very helpful 🤗 💟

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok thanks mate.
@SSE4 could you suggest someone who could help with this? (I'm not sure who I should tag as Triage Person)

21 changes: 15 additions & 6 deletions recipes/cgns/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run

from conans import ConanFile, CMake, tools

required_conan_version = ">=1.52.0"

class CgnsTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/cgns/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 CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(test_package ../test_package/test_package.cpp)
target_link_libraries(test_package ${CONAN_LIBS})
18 changes: 18 additions & 0 deletions recipes/cgns/all/test_v1_package/conanfile.py
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.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 1 addition & 1 deletion recipes/cgns/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"3.4.1":
"4.3.0":
folder: all