FreeCAD / homebrew-freecad

Homebrew recipes for FreeCAD
55 stars 34 forks source link

subsquent cmake configures fail, but clearing the cmake cache allows cmake to run (HDF5) #583

Open ipatch opened 1 month ago

ipatch commented 1 month ago

using my current hdf5 patch to allow cmake to find a hdf5 installation from homebrew, the initial cmake command will complete, but if the cmake command is rerun in the same directory, the subsequent run will fail with the below error output,

CMake Warning at /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/patches/99/FindHDF5.cmake:735 (message):
  HDF5 Version found for language C, 1.14.4.3 is different than previously
  found version 1.14.4
Call Stack (most recent call first):
  /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/VTK-vtk-module-find-packages.cmake:444 (find_package)
  /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/vtk-config.cmake:166 (include)
  cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:59 (find_package)
  CMakeLists.txt:71 (SetupSalomeSMESH)

CMake Error at /Users/chris/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_HL_LIBRARIES) (found
  version "1.14.4")
Call Stack (most recent call first):
  /Users/chris/homebrew/Cellar/cmake/3.30.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/patches/99/FindHDF5.cmake:1006 (find_package_handle_standard_args)
  /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/VTK-vtk-module-find-packages.cmake:444 (find_package)
  /Users/chris/homebrew/opt/vtk/lib/cmake/vtk-9.3/vtk-config.cmake:166 (include)
  cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:59 (find_package)
  CMakeLists.txt:71 (SetupSalomeSMESH)

-- Configuring incomplete, errors occurred!
-- Cache values
ipatch commented 1 month ago

it seems updating the cmake logic in the patch to look like the below allows the cmake run to continue without encountering the above error,

if(HOMEBREW_PREFIX)
                  unset(HDF5_FOUND CACHE)
                  # set(HDF5_ROOT "${HOMEBREW_PREFIX}/opt/hdf5" CACHE PATH "path to HDF5 installation")
                  # set(HDF5_DIR "/Users/chris/homebrew/opt/hdf5/lib/cmake/hdf5" CACHE PATH "")
                  # set(HDF5_HL_LIBRARIES "/Users/chris/homebrew/opt/hdf5/lib/libhdf5_hl.dylib")
                  # find_package(HDF5 COMPONENTS C HL REQUIRED)
                  find_package(HDF5 REQUIRED COMPONENTS C CXX HL)
                  message("--------------------------------------------")
                  message("ipatch, manually set hdf5_root, cmake build of hdf5 breaks h5cc")
                  message(VERBOSE "HDF5_LIBRARIES                          : ${HDF5_LIBRARIES}")
                  message(VERBOSE "HDF5_C_HL_LIBRARIES                     : ${HDF5_C_HL_LIBRARIES}")
                  message(VERBOSE "HDF5_HL_LIBRARIES                       : ${HDF5_HL_LIBRARIES}")
                  message(VERBOSE "HDF5_C_LIBRARIES                        : ${HDF5_C_LIBRARIES}")
                  message("--------------------------------------------")
                else()

obviously an updated patch will be required.

some useful links below,

https://github.com/Homebrew/homebrew-core/issues/159691

https://gitweb.gentoo.org/repo/gentoo.git/tree/sci-libs/hdf5/hdf5-1.14.4_p3-r1.ebuild

ipatch commented 4 days ago

the below patch file should fix the above mentioned error in this issue. all that is left is to integrate the patch file in the various freecad formulas in this repo.

https://github.com/FreeCAD/homebrew-freecad/blob/52f707a3506cf8233129ed9e6e750f4288f32945/patches/freecad%400.21.2_py310-hdf5-cmake-fix.patch