Split static targets into separate optional target [UPDATED] (#6216)

Build-tree exports can't diverge from install-tree exports — the export(EXPORT ...) reads directly from the install export sets. No manual list to keep in sync.

Removed 3 global variables (HDF5_STATIC_LIBRARIES_TO_EXPORT, HDF5_JAVA_LIBRARIES_TO_EXPORT, HDF5_UTILS_TO_EXPORT) and their ~21 set_global_variable calls across tool/utility files.

Fixed the static-only build bug in the PR where the base export set was guarded by BUILD_SHARED_LIBS, breaking tools export.

Removed redundant utils in export files — the PR was dumping tools into all three build-tree export files (java, static, shared). Now they correctly appear only in the base export.
This commit is contained in:
Scot Breitenfeld
2026-02-24 17:04:25 -06:00
committed by GitHub
parent 3bd0f17857
commit a7ec64a857
11 changed files with 269 additions and 115 deletions
+27 -8
View File
@@ -52,6 +52,24 @@ endif ()
#-----------------------------------------------------------------------------
if (NOT HDF5_EXTERNALLY_CONFIGURED)
if (HDF5_EXPORTED_TARGETS)
if (HDF5_ENABLE_JNI)
install (
EXPORT ${HDF5_EXPORTED_TARGETS}_java
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_java-targets.cmake
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
COMPONENT configinstall
)
endif ()
if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
install (
EXPORT ${HDF5_EXPORTED_TARGETS}_static
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_static-targets.cmake
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
COMPONENT configinstall
)
endif ()
install (
EXPORT ${HDF5_EXPORTED_TARGETS}
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
@@ -61,16 +79,17 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED)
)
endif ()
#-----------------------------------------------------------------------------
# Export all exported targets to the build tree for use by parent project
#-----------------------------------------------------------------------------
export (
TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} ${HDF5_UTILS_TO_EXPORT}
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
)
endif ()
#-----------------------------------------------------------------------------
# Export all exported targets to the build tree for use by parent project
#-----------------------------------------------------------------------------
export (
TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} ${HDF5_UTILS_TO_EXPORT}
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
)
#-----------------------------------------------------------------------------
# Set includes needed for build
#-----------------------------------------------------------------------------