mixxx icon indicating copy to clipboard operation
mixxx copied to clipboard

FindRubberband: Make sure sleefdft is present before linking it

Open fwcd opened this issue 10 months ago • 5 comments

I have encountered configuration errors when Sleef was built without SleefDFT (FindSleef.cmake seems to handle this correctly). To avoid this, this PR makes sure to only link Sleef if the DFT library is present.

In my case this happened because Homebrew Sleef (which apparently is not built with DFT) slipped into the build. While this is not ideal, we should at least make sure that we build against a working version of Sleef.

fwcd avatar Apr 10 '24 00:04 fwcd

IIUC we cannot use find_package for that since we locate SleefDFT together with Sleef in FindSleef.cmake (we would need a separate FindSleefDFT.cmake or similar). Maybe adding a warning to FindSleef.cmake if Sleef was found without DFT would be appropriate?

fwcd avatar Apr 10 '24 12:04 fwcd

I have added a warning, which should hopefully highlight the problem if someone is wondering why we don't link their Sleef:

CMake Warning at cmake/modules/FindSleef.cmake:145 (message):
  Sleef found at /opt/homebrew/lib/libsleef.a does not have sleefdft, this
  means static builds will not link it with Rubberband! Perhaps you meant to
  use some other version of Sleef?

fwcd avatar Apr 11 '24 01:04 fwcd

I think the best way would be to make find_package(Sleef COMPONENTS sleefdft)

This can be done by adding the following fo FindSleef.cmake

foreach (_component ${SLEEF_FIND_COMPONENTS})
    if (${_component} STREQUAL "sleefdft")
        find_library(SleefDFT_LIBRARY
          NAMES sleefdft
          PATHS ${PC_Sleef_LIBRARY_DIRS})
        mark_as_advanced(SleefDFT_LIBRARY)
        set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} SleefDFT_LIBRARY)
    endif() 
endforeach ()

....

find_package_handle_standard_args(
  Sleef
  REQUIRED_VARS Sleef_INCLUDE_DIR Sleef_LIBRARY ${ADDITIONAL_REQUIRED_VARS}
  VERSION_VAR Sleef_VERSION)

daschuer avatar Apr 11 '24 05:04 daschuer

Great suggestion, thanks! I have made the search for Sleef components a bit more generic even and dropped the 'sleef' prefix (since at least according to the project's CMakeLists they all follow the same naming scheme), so Sleef::sleefdft becomes Sleef::dft (and find_package(Sleef COMPONENTS dft), Sleef_dft_FOUND etc.)

fwcd avatar Apr 11 '24 23:04 fwcd

This PR is marked as stale because it has been open 90 days with no activity.

github-actions[bot] avatar Aug 06 '24 00:08 github-actions[bot]