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

CMake can't find SndFile (Ubuntu 24.04 / KDE neon) #1445

Open
mrbumpy409 opened this issue Dec 8, 2024 · 15 comments
Open

CMake can't find SndFile (Ubuntu 24.04 / KDE neon) #1445

mrbumpy409 opened this issue Dec 8, 2024 · 15 comments

Comments

@mrbumpy409
Copy link

Compiling the latest 2.4.1 release on KDE neon (Ubuntu 24.04 base), CMake cannot find SndFile:

-- Could NOT find SndFile (Set SndFile_DIR to the directory containing its CMake config) (Required is at least version 1.2.1)

Version 1.2.2 of the libsndfile1 and libsndfile1-dev packages are installed from the system repository, but CMake can't find them. All other dependencies are detected correctly. I cannot see any obvious CMake config files within the files installed by libsndfile1-dev. Here is the list of files in that package:

/usr/include/sndfile.h
/usr/include/sndfile.hh
/usr/lib/x86_64-linux-gnu/libsndfile.so
/usr/lib/x86_64-linux-gnu/pkgconfig/sndfile.pc
/usr/lib/x86_64-linux-gnu/sndfile/tests/aiff_rw_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/alaw_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/benchmark
/usr/lib/x86_64-linux-gnu/sndfile/tests/channel_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/checksum_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/chunk_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/command_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/compression_size_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/cpp_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/dither_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/dwvw_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/error_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/external_libs_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/fix_this
/usr/lib/x86_64-linux-gnu/sndfile/tests/floating_point_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/format_check_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/header_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/headerless_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/largefile_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/locale_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/long_read_write_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/lossy_comp_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/misc_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/mpeg_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/multi_file_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/ogg_opus_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/ogg_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/pcm_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/peak_chunk_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/pedantic-header-test.sh
/usr/lib/x86_64-linux-gnu/sndfile/tests/pipe_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/raw_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/rdwr_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/scale_clip_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/sfversion
/usr/lib/x86_64-linux-gnu/sndfile/tests/stdin_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/stdio_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/stdout_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/string_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/test_main
/usr/lib/x86_64-linux-gnu/sndfile/tests/test_wrapper.sh
/usr/lib/x86_64-linux-gnu/sndfile/tests/ulaw_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/virtual_io_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/win32_ordinal_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/win32_test
/usr/lib/x86_64-linux-gnu/sndfile/tests/write_read_test
/usr/share/doc-base/libsndfile1-dev.libsndfile
/usr/share/doc/libsndfile1-dev/AUTHORS.gz
/usr/share/doc/libsndfile1-dev/CONTRIBUTING.md
/usr/share/doc/libsndfile1-dev/NEWS.OLD.gz
/usr/share/doc/libsndfile1-dev/README
/usr/share/doc/libsndfile1-dev/SECURITY.md
/usr/share/doc/libsndfile1-dev/changelog.Debian.gz
/usr/share/doc/libsndfile1-dev/copyright
/usr/share/doc/libsndfile1-dev/examples/Makefile
/usr/share/doc/libsndfile1-dev/examples/generate.c
/usr/share/doc/libsndfile1-dev/examples/list_formats.c
/usr/share/doc/libsndfile1-dev/examples/make_sine.c
/usr/share/doc/libsndfile1-dev/examples/sfprocess.c
/usr/share/doc/libsndfile1-dev/examples/sndfile-loopify.c
/usr/share/doc/libsndfile1-dev/examples/sndfile-to-text.c
/usr/share/doc/libsndfile1-dev/markdown/FAQ.md.gz
/usr/share/doc/libsndfile1-dev/markdown/api.md.gz
/usr/share/doc/libsndfile1-dev/markdown/bugs.md
/usr/share/doc/libsndfile1-dev/markdown/command.md.gz
/usr/share/doc/libsndfile1-dev/markdown/embedded_files.md
/usr/share/doc/libsndfile1-dev/markdown/formats.md.gz
/usr/share/doc/libsndfile1-dev/markdown/index.md.gz
/usr/share/doc/libsndfile1-dev/markdown/libsndfile.css
/usr/share/doc/libsndfile1-dev/markdown/libsndfile.jpg
/usr/share/doc/libsndfile1-dev/markdown/lists.md
/usr/share/doc/libsndfile1-dev/markdown/new_file_type_howto.md.gz
/usr/share/doc/libsndfile1-dev/markdown/octave.md
/usr/share/doc/libsndfile1-dev/markdown/print.css
/usr/share/doc/libsndfile1-dev/markdown/sndfile_info.md
/usr/share/doc/libsndfile1-dev/markdown/tutorial.md
/usr/share/doc/libsndfile1-dev/markdown/win32.md
@mrbumpy409 mrbumpy409 added the bug label Dec 8, 2024
@derselbst
Copy link
Member

derselbst commented Dec 8, 2024

Starting with 2.4.0 fluidsynth relies on libsndfile's CMake configuration files in order to successfully discover libsndfile. Those are unfortunately not included in the Ubuntu package. So ideally this issue should be brought to https://launchpad.net/ubuntu/+source/libsndfile/+bugs asking to include the CMake config files like SndFileConfig.cmake and friends in the libsndfile1-dev package.

Edit: From my understanding one would only need to add

usr/lib/cmake/SndFile/*

to this file: https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/libsndfile1-dev.install?h=applied/ubuntu/noble-proposed

@LocutusOfBorg You seem to be one of the maintainers of Ubuntu's libsndfile package - may I ask you to take care of this?


Alternatively, we could reintroduce our custom discovery magic through pkg-config, that I removed here:
https://github.com/FluidSynth/fluidsynth/pull/1435/files#diff-591a514eb6352bf5970e0a844be3eb2266bff8941741dad3d26bf493e40b0a07
But I would really like to avoid that.

@pedrolcl
Copy link
Contributor

pedrolcl commented Dec 9, 2024

The problem is that SndFile has two build systems: the old traditional autotools-based build system, and a newer cmake based one. It shares a similar history with Fluidsynth, except that we removed the autotools once it was clear that cmake is better. The SndFile project did not perform this basic hygiene, and still has both. When building SndFile with auto-tools, the cmake support scripts are not used, generated or installed, and Fluidsynth is unable to find SndFile in these cases.

Another layer of the problem is the lazy linux distros/maintainers, that prefer the old auto-tools better than learning the new cmake command. They will be unable to build the new Fluidsynth release, but anyway these lazy maintainers usually keep their deprecated packages for months or even years. This was anticipated here.

Here are some links for people wanting to complain:

@LocutusOfBorg
Copy link

commit 4cdd9af
Author: Tom M. [email protected]
Date: Sat Nov 23 11:52:46 2024 +0100

Fix CI builds (#1435)

:100644 100644 c12380d8 a696b473 M .azure/azure-pipelines-android.yml
:100644 100644 ff498d64 a0b85ef5 M .azure/azure-pipelines-win.yml
:100644 000000 2de2f41a 00000000 D cmake_admin/FindFLAC.cmake
:100644 000000 8044c941 00000000 D cmake_admin/FindOgg.cmake
:100644 000000 271bb061 00000000 D cmake_admin/FindSndFile.cmake
:100644 000000 0865c3ea 00000000 D cmake_admin/FindVorbis.cmake
:100644 000000 cd8b4c8a 00000000 D cmake_admin/Findmp3lame.cmake
:100644 000000 3cb35167 00000000 D cmake_admin/Findmpg123.cmake
:100644 100644 cb262879 73f0cd94 M src/fluidsynth.c

@LocutusOfBorg
Copy link

Theoretically, one should provide a new find package, and the old one as fallback, to help backporting of your fluidsynth to older releases.
I'll try to cope with sndfile for Debian and Ubuntu, but for sure, changing the autotools to cmake can't be updated into an already released LTS release nor any other stable
(lots of regressions can be introduced by such changes!)

@derselbst
Copy link
Member

Sorry, I forgot about the fact that libsndfile still has two build systems. I do understand Pedros point that distro packages should be migrated and updated accordingly. But I also understand Locutus that such a change won't make it into any LTS branch.

Locutus, would you prefer if someone files a ticket at launchpad, or Debian, or elsewhere?

I think for the time being we should fall back to the previous pkg-config based discovery. Not doing so would definitely result in many bug reports like this one being filed here on Github, which doesn't really help anyone.

@pedrolcl
Copy link
Contributor

I forgot about the fact that libsndfile still has two build systems. I do understand Pedros point that distro packages should be migrated and updated accordingly. But I also understand Locutus that such a change won't make it into any LTS branch.

I don't understand why not. When using the CMake based build system, the pkg-config .pc file is generated as well, and the package is discoverable and can be configured by other build systems. But when using the auto-tools build system, only the pkg-config .pc is generated, and other packages like Fluidsynth that expect .cmake configuration files are left in the cold.

@LocutusOfBorg
Copy link

I tried to use cmake:
https://github.com/libsndfile/libsndfile/blob/0d3f80b7394368623df558d8ba3fee6348584d4d/CMakeLists.txt#L71
option (BUILD_SHARED_LIBS "Build shared libraries" OFF)
if (BUILD_SHARED_LIBS AND BUILD_TESTING)
set (BUILD_TESTING OFF)
message ("Build testing required static libraries. To prevent build errors BUILD_TESTING disabled.")
endif ()

Switching to cmake means no tests during build, this, for example, is a big regression compared with autotools.
Cmake should not loose this kind of functionalities. (I'll try to fix it up)

@pedrolcl
Copy link
Contributor

Switching to cmake means no tests during build, this, for example, is a big regression compared with autotools.
Cmake should not loose this kind of functionalities. (I'll try to fix it up)

You may look into the msys2 approach:
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-libsndfile/PKGBUILD

In short: they build it twice, static and shared. The unit tests are not run, but they install both versions (not only of libsndfile, but of every package).

@LocutusOfBorg
Copy link

problem is after some quick debug:

  1. they don't build both shared and static library in cmake, due to configure problems.
  2. the shared library is not exporting some functions used by tests

their solution is:

  1. link the static library with tests
  2. disable tests with shared library.

my solution is:

  1. create a static library internal just for tests, and use it for tests
  2. link it

Will share my progresses once I finish.

(building twice is a sad approach in Debian packaging, not upstreamable and difficult to maintain. I'm not maintainer for the package, so my solution should be preferrably clean and short)

@LocutusOfBorg
Copy link

This is something that works, but really needs cleanup and upstream apply
libsndfile/libsndfile#1054

@pedrolcl
Copy link
Contributor

This is something that works, but really needs cleanup and upstream apply libsndfile/libsndfile#1054

So, to avoid building the package twice, your approach is to build the sources twice?

If you add several targets with the same sources, every source will be compiled again for each target. To avoid this we use an object library in fluidsynth:

add_library ( libfluidsynth-OBJ OBJECT

Which is used for building the library (shared or static):

add_library ( libfluidsynth
$<TARGET_OBJECTS:libfluidsynth-OBJ>
${public_main_HEADER}
${public_HEADERS}
${MACOSX_FRAMEWORK_SOURCE_HACK}
)

And it is also linked to the unit tests:

target_link_libraries( ${_test} libfluidsynth-OBJ )

@derselbst
Copy link
Member

Ok, so since there are apparently a few drawbacks in libsndfile's cmake based buildsystem, I have created a PR to restore our previous discovery magic. I have renamed our cmake find script to FindSndFileLegacy.cmake so that by default find_package attempts to use Libsndfile's cmake config - not sure if that is necessary, feel free to have a look Pedro.

If I find some time over the holidays, I'll try to add the object library to libsndfile as pointed out by Pedro.

@pedrolcl
Copy link
Contributor

Ok, so since there are apparently a few drawbacks in libsndfile's cmake based buildsystem, I have created a PR to restore our previous discovery magic. I have renamed our cmake find script to FindSndFileLegacy.cmake so that by default find_package attempts to use Libsndfile's cmake config - not sure if that is necessary, feel free to have a look Pedro.

I don't see a lot of drawbacks. The only thing is the incompatibility of unit tests with the shared library, and this would be only a problem if you need to run the unit tests, which should be done only when the maintainer apply patches before the upstream project does. Otherwise, the insistence of distros on running all unit tests in all circumstances is wasting CPU cycles, throwing up carbon dioxide, and a crime against the environment.

But another argument against your revert: by doing that you may be holding back the project, just because others would like to hold back the world, instead of encouraging moving all of us ahead. The same that has held Linux irrelevant on desktops for decades.

If I find some time over the holidays, I'll try to add the object library to libsndfile as pointed out by Pedro.

It is your time to waste, but the libsndfile project has right now 143 open issues and 25 open pull requests (some are 4 years old). I guess that yours may be held there for months or even years (you already have opened an issue last month). Good luck, though.

@derselbst
Copy link
Member

I disagree with you, Pedro. Being able to execute the unit tests is a legitimate reason - even for a package maintainer - as it ensures, that a particular build with a particular toolchain and configuration (compile flags, project internal build-flags, etc), works in such a way as it was intended by the developers.

The intention behind #1454 is not to hold back the project, but rather to avoid breaking functionality that worked before. BTW, that's the same motivation why we're still using C90 and C++98, since we do have at least one WindowsXP user, and I'm not the one who wants to deliberate break stuff, just for the sake of moving forward.

I do recognize that the libsndfile upstream dev has gone stale a bit. Yet, I do not consider it a waste of time, as is would bring the project forward. Pls. don't be so negative Pedro. From what I have perceived from Locutus, he is willing to port libsndfile to its CMake based buildsystem, when this issue has been sorted (provided, no other flaw is discovered). Not sure if I'll find the time though, because four more bugs have been filed recently...

@LocutusOfBorg
Copy link

Hello @derselbst I'm willing to finish the work, I just had to fix like 10 other packages, but this one will come soon :)

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

No branches or pull requests

4 participants