Skip to content

Conversation

@opoplawski
Copy link
Contributor

@opoplawski opoplawski commented Dec 14, 2025

Fedora packaging guidelines requires that static libraries are shipped in a separate -static sub-package and are not used by other Fedora packages when building. This causes issues with many cmake projects that put both the shared and static targets in the same file, like the following:

CMake Error at /usr/lib64/cmake/hdf5/hdf5-targets.cmake:298 (message):
  The imported target "hdf5-static" references the file

     "/usr/lib64/libhdf5.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib64/cmake/hdf5/hdf5-targets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib64/cmake/hdf5/hdf5-config.cmake:222 (include)
  /usr/share/cmake/Modules/FindHDF5.cmake:513 (find_package)
  CMakeLists.txt:179 (find_package)

We have submitted similar patches to other upstream projects to put the static targets into a separate optional file. This patch is not completely polished - it lacks some symmetry in how names and variables are handled. But I at least wanted to put it out there for comment.


Important

Separate static library targets into optional -static CMake files for HDF5 components to comply with Fedora packaging guidelines.

  • Behavior:
    • Separate static library targets into -static CMake files for core, tools, and language bindings.
    • Static libraries are now optional and exported separately.
  • CMake Configuration:
    • Add HDF5_STATIC_LIBRARIES_TO_EXPORT variable to track static libraries.
    • Modify CMakeLists.txt in src, tools/lib, c++/src, fortran/src, hl/src, hl/c++/src, hl/fortran/src to handle static libraries separately.
    • Update install() commands to export static libraries to -static targets.
  • Misc:
    • Update hdf5-config.cmake.in to include optional static targets.
    • Ensure backward compatibility by maintaining shared library targets.

This description was created by Ellipsis for 846bc8f. You can customize this summary. It will automatically update as commits are pushed.

@opoplawski
Copy link
Contributor Author

Looks like we're running into problems with this:

# Load information for each installed configuration.
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/hdf5-targets-*.cmake")
foreach(_cmake_config_file IN LISTS _cmake_config_files)
  include("${_cmake_config_file}")
endforeach()

picking up the -static files, so I need a different name for it.

@opoplawski
Copy link
Contributor Author

Fedora also splits out the java components, so it needs a new target as well.

@jhendersonHDF
Copy link
Collaborator

Hi @opoplawski,

at a first glance this seems reasonable and unlikely to be controversial. Out of curiosity, do you happen to have a link to Fedora's packaging guidelines so we can read up on them more regarding this?

@jhendersonHDF jhendersonHDF self-assigned this Dec 23, 2025
@opoplawski
Copy link
Contributor Author

Here is a place to start: https://docs.fedoraproject.org/en-US/packaging-guidelines/#packaging-static-libraries

endif ()
include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
if ( @BUILD_STATIC_LIBS@ )
include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@_static-targets.cmake OPTIONAL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about best practices, but using OPTIONAL for these seems like it would hide errors in the cases where users were expecting that the static targets file would exist and may be confusing

if ( @BUILD_STATIC_LIBS@ )
include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@_static-targets.cmake OPTIONAL)
endif ()
if ( @HDF5_BUILD_JAVA@ )
Copy link
Collaborator

Choose a reason for hiding this comment

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

OPTIONAL may make sense here however, as HDF5_BUILD_JAVA is checked here, whereas the ..._java-targets.cmake file is created when HDF5_ENABLE_JNI is true rather than HDF5_BUILD_JAVA. I believe that means the ..._java-targets.cmake file won't exist when the Java implementation uses FFM instead of the old JNI, but the FFM source doesn't currently appear to have anything to export as a target anyway.

Copy link
Collaborator

@jhendersonHDF jhendersonHDF left a comment

Choose a reason for hiding this comment

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

Generally looks good, just a couple comments around the use of OPTIONAL when including target files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

2 participants