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

[bug] hdf5/1.12.1 (any version) : Include the module_file in cmake_build_modules for targets #10836

Closed
Closed
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
42 changes: 26 additions & 16 deletions recipes/hdf5/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,52 @@ sources:
"1.10.6":
url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_10_6.tar.gz"
sha256: "e524b374b1c6f14f1aa87595c0761608c861fe7838549dab84639ae564ff48e8"
"1.10.5":
url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_10_5.tar.gz"
sha256: "22a4a48f94b013e9fd482c0bb0251de02ff9963787a107c5dde26a3f903b3b90"
#"1.10.5":
# url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_10_5.tar.gz"
# sha256: "22a4a48f94b013e9fd482c0bb0251de02ff9963787a107c5dde26a3f903b3b90"
"1.8.21":
url: "https://github.com/HDFGroup/hdf5/archive/hdf5-1_8_21.tar.gz"
sha256: "753520e34a576a64809b8e02d9c015d6126f7974f678c7417a60492d835a88f4"
patches:
"1.12.1":
- patch_file: "patches/conanize-link-szip-1.12.1+.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-zlib-1.12.1+.patch"
base_path: "source_subfolder"
"1.12.0":
- patch_file: "patches/conanize-link-szip-1.10.5+.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-zlib-1.10.5+.patch"
base_path: "source_subfolder"
"1.10.6":
- patch_file: "patches/fix-missing-function-prototypes-1.10.5+.patch"
base_path: "source_subfolder"
- patch_file: "patches/fix-missing-function-prototypes-1.10.6.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-szip-1.10.5+.patch"
base_path: "source_subfolder"
"1.10.5":
- patch_file: "patches/fix-missing-function-prototypes-1.10.5+.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-szip-1.10.5+.patch"
base_path: "source_subfolder"
- patch_file: "patches/build-either-static-or-shared-1.10.5.patch"
base_path: "source_subfolder"
- patch_file: "patches/mingw-cmake-size-type-checks-1.10.5.patch"
base_path: "source_subfolder"
- patch_file: "patches/mingw-fix-prefix-lib.patch"
base_path: "source_subfolder"
- patch_file: "patches/mingw-unused-ellipses.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-zlib-1.10.5+.patch"
base_path: "source_subfolder"
#"1.10.5":
# - patch_file: "patches/fix-missing-function-prototypes-1.10.5+.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/conanize-link-szip-1.10.5+.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/build-either-static-or-shared-1.10.5.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/mingw-cmake-size-type-checks-1.10.5.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/mingw-fix-prefix-lib.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/mingw-unused-ellipses.patch"
# base_path: "source_subfolder"
# - patch_file: "patches/conanize-link-zlib-1.10.5+.patch"
# base_path: "source_subfolder"
"1.8.21":
- patch_file: "patches/conanize-link-szip-1.8.21.patch"
base_path: "source_subfolder"
- patch_file: "patches/conanize-link-zlib-1.8.21.patch"
base_path: "source_subfolder"
- patch_file: "patches/build-either-static-or-shared-1.8.21.patch"
base_path: "source_subfolder"
- patch_file: "patches/mingw-cmake-size-type-checks-1.8.21.patch"
Expand Down
30 changes: 22 additions & 8 deletions recipes/hdf5/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Hdf5Conan(ConanFile):
"parallel": False,
}

generators = "cmake"
generators = "cmake", "cmake_find_package_multi"

@property
def _source_subfolder(self):
Expand Down Expand Up @@ -176,7 +176,7 @@ def _components(self):
}

@staticmethod
def _create_cmake_module_alias_targets(module_file, targets, is_parallel):
def _create_cmake_module_alias_targets(module_file, targets):
content = ""
for alias, aliased in targets.items():
content += textwrap.dedent("""\
Expand All @@ -193,14 +193,23 @@ def _create_cmake_module_alias_targets(module_file, targets, is_parallel):
set_property(TARGET hdf5::hdf5_hl_cpp PROPERTY INTERFACE_LINK_LIBRARIES HDF5::HL_CXX)
endif()
""")
content += textwrap.dedent("set(HDF5_IS_PARALLEL {})".format("ON" if is_parallel else "OFF"))
tools.save(module_file, content)

@staticmethod
def _create_cmake_module_variables(module_file, is_parallel):
content = "set(HDF5_IS_PARALLEL {})".format("ON" if is_parallel else "OFF")
tools.save(module_file, content)

@property
def _module_file_rel_path(self):
def _module_file_targets_rel_path(self):
return os.path.join("lib", "cmake",
"conan-official-{}-targets.cmake".format(self.name))

@property
def _module_file_variables_rel_path(self):
return os.path.join("lib", "cmake",
"conan-official-{}-variables.cmake".format(self.name))

def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
Expand All @@ -211,8 +220,11 @@ def package(self):
# but component targets have a lower case namespace prefix. hdf5::hdf5 refers to the C library only
components = self._components()
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._module_file_rel_path),
{"hdf5::{}".format(component["alias_target"]): "HDF5::{}".format(component["component"]) for component in components.values()},
os.path.join(self.package_folder, self._module_file_targets_rel_path),
{"hdf5::{}".format(component["alias_target"]): "HDF5::{}".format(component["component"]) for component in components.values()}
)
self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_file_variables_rel_path),
self.options.get_safe("parallel", False)
)

Expand All @@ -229,14 +241,15 @@ def _config_libname(lib):

self.cpp_info.components[component_name].set_property("cmake_target_name", f"hdf5::{alias_target}")
self.cpp_info.components[component_name].set_property("pkg_config_name", alias_target)
self.cpp_info.components[component_name].set_property("cmake_build_modules", [self._module_file_variables_rel_path, self._module_file_variables_rel_path])
self.cpp_info.components[component_name].libs = [_config_libname(alias_target)]
self.cpp_info.components[component_name].requires = requirements

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components[component_name].names["cmake_find_package"] = component
self.cpp_info.components[component_name].names["cmake_find_package_multi"] = component
self.cpp_info.components[component_name].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components[component_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
self.cpp_info.components[component_name].build_modules["cmake_find_package"] = [self._module_file_targets_rel_path, self._module_file_variables_rel_path]
self.cpp_info.components[component_name].build_modules["cmake_find_package_multi"] = [self._module_file_targets_rel_path, self._module_file_variables_rel_path]

self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "HDF5")
Expand All @@ -259,6 +272,7 @@ def _config_libname(lib):
add_component("hdf5_hl", **components["hdf5_hl"])
if self.options.get_safe("enable_cxx"):
add_component("hdf5_hl_cpp", **components["hdf5_hl_cpp"])


# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["cmake_find_package"] = "HDF5"
Expand Down
58 changes: 58 additions & 0 deletions recipes/hdf5/all/patches/conanize-link-zlib-1.10.5+.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake
index 5a89564562..9eda8bfe71 100644
--- a/CMakeFilters.cmake
+++ b/CMakeFilters.cmake
@@ -47,49 +47,13 @@ endif ()
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF)
if (HDF5_ENABLE_Z_LIB_SUPPORT)
- if (NOT H5_ZLIB_HEADER)
- if (NOT ZLIB_USE_EXTERNAL)
- find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared)
- if (NOT ZLIB_FOUND)
- find_package (ZLIB) # Legacy find
- if (ZLIB_FOUND)
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES})
- set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_LIBRARIES})
- endif ()
- endif ()
- endif ()
- if (ZLIB_FOUND)
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- set (H5_ZLIB_HEADER "zlib.h")
- set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR})
- set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
- else ()
- if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
- EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- message (STATUS "Filter ZLIB is built")
- else ()
- message (FATAL_ERROR " ZLib is Required for ZLib support in HDF5")
- endif ()
- endif ()
- else ()
- # This project is being called from within another and ZLib is already configured
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- endif ()
+ set (H5_HAVE_FILTER_DEFLATE 1)
+ set (H5_HAVE_ZLIB_H 1)
+ set (H5_HAVE_LIBZ 1)
if (H5_HAVE_FILTER_DEFLATE)
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE")
endif ()
- if (BUILD_SHARED_LIBS)
- set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_SHARED_LIBRARY})
- endif ()
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY})
- INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS})
+ set (LINK_COMP_LIBS ${LINK_COMP_LIBS} "CONAN_PKG::zlib")
message (STATUS "Filter ZLIB is ON")
endif ()

54 changes: 54 additions & 0 deletions recipes/hdf5/all/patches/conanize-link-zlib-1.12.1+.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--- CMakeFilters.cmake 2021-07-02 05:26:37.000000000 +0800
+++ CMakeFilters.cmake 2022-05-29 23:14:46.710480904 +0800
@@ -57,47 +57,13 @@
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF)
if (HDF5_ENABLE_Z_LIB_SUPPORT)
- if (NOT H5_ZLIB_HEADER)
- if (NOT ZLIB_USE_EXTERNAL)
- find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared)
- if (NOT ZLIB_FOUND)
- find_package (ZLIB) # Legacy find
- if (ZLIB_FOUND)
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES})
- endif ()
- endif ()
- endif ()
- if (ZLIB_FOUND)
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- set (H5_ZLIB_HEADER "zlib.h")
- set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR})
- set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
- else ()
- if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
- EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
- message (VERBOSE "Filter ZLIB is built")
- endif ()
- else ()
- message (FATAL_ERROR " ZLib is Required for ZLib support in HDF5")
- endif ()
- endif ()
- else ()
- # This project is being called from within another and ZLib is already configured
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- endif ()
+ set (H5_HAVE_FILTER_DEFLATE 1)
+ set (H5_HAVE_ZLIB_H 1)
+ set (H5_HAVE_LIBZ 1)
if (H5_HAVE_FILTER_DEFLATE)
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE")
endif ()
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY})
- INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS})
+ set (LINK_COMP_LIBS ${LINK_COMP_LIBS} "CONAN_PKG::zlib")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
message (VERBOSE "Filter ZLIB is ON")
endif ()
58 changes: 58 additions & 0 deletions recipes/hdf5/all/patches/conanize-link-zlib-1.8.21.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake
index 71dabb15d4..bacd6c4f28 100644
--- a/CMakeFilters.cmake
+++ b/CMakeFilters.cmake
@@ -39,49 +39,13 @@ endif ()
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF)
if (HDF5_ENABLE_Z_LIB_SUPPORT)
- if (NOT H5_ZLIB_HEADER)
- if (NOT ZLIB_USE_EXTERNAL)
- find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared)
- if (NOT ZLIB_FOUND)
- find_package (ZLIB) # Legacy find
- if (ZLIB_FOUND)
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES})
- set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_LIBRARIES})
- endif ()
- endif ()
- endif ()
- if (ZLIB_FOUND)
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- set (H5_ZLIB_HEADER "zlib.h")
- set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR})
- set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
- else ()
- if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
- EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- message (STATUS "Filter ZLIB is built")
- else ()
- message (FATAL_ERROR " ZLib is Required for ZLib support in HDF5")
- endif ()
- endif ()
- else ()
- # This project is being called from within another and ZLib is already configured
- set (H5_HAVE_FILTER_DEFLATE 1)
- set (H5_HAVE_ZLIB_H 1)
- set (H5_HAVE_LIBZ 1)
- endif ()
+ set (H5_HAVE_FILTER_DEFLATE 1)
+ set (H5_HAVE_ZLIB_H 1)
+ set (H5_HAVE_LIBZ 1)
if (H5_HAVE_FILTER_DEFLATE)
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE")
endif ()
- if (BUILD_SHARED_LIBS)
- set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_SHARED_LIBRARY})
- endif ()
- set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY})
- INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS})
+ set (LINK_COMP_LIBS ${LINK_COMP_LIBS} "CONAN_PKG::zlib")
message (STATUS "Filter ZLIB is ON")
endif ()

4 changes: 2 additions & 2 deletions recipes/hdf5/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ versions:
folder: all
"1.10.6":
folder: all
"1.10.5":
folder: all
#"1.10.5":
# folder: all
"1.8.21":
folder: all